Page 1 of 1

Need help with scenery

PostPosted: Sat Apr 10, 2010 11:35 pm
by sillydraco
okay, so basically i want the background and foreground of the game (its a sidescroller :3) to move while the character walks. Ever played Yoshi's Island? just like that. like the mountains in the background moving slowly past, as well as the leaves and such in the foreground moving past a little faster. ive always loved how games do that, just because it makes it look a lot better than just an animation moving to and fro on a still environment. heres what i mean:

scalesnfuzz.com/yoshi.avi

notice as he runs to the right the mountains move slowly by like they do when you look out the window of your car. also, like when viewed from inside a moving car, the leaves and flowers move by a tad faster than you are. also, i tried setting the View to move-to > draw actor (view to draco) so the view would trail the character. it made the movement look a lot smoother but when the view caught up (as when i stop) the view shakes a lot, moving back and forth. not sure why it does that :(


also heres the zip and such, as well as a .ged file and a .exe ^^
scalesnfuzz.com/Platform.zip

Re: Need help with scenery

PostPosted: Sat Apr 10, 2010 11:41 pm
by Hblade
for the background, use this code:
Code: Select all
x = view.x / 2;
y = view.y / 2;

Now the mountians will move slowly both up and down. To get them only to move slowly when going left and right, and not up, simply remove the y = view.y / 2.

For the leaves:
Code: Select all
x = view.x * 1.5;
y = view.y * 1.5;

Asuming that the leaves are stationary.

However if your leaves are moving along with the screen, blowing in the wind, but you still want the same effect, you have to do this:
Code: Select all
int tx;
int ty;
tx = x;
ty = y;
x = view.x*1.5 - tx;
y = view.y*1.5 - ty;

That part's un tested though, so lemme know if it works :D

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 1:07 am
by sillydraco
i tried a couple of things with the code, but it didnt seem to work (of course i could be doing something wrong too ^^) and then i realised i hadnt posted a link to the .ged file for the game >.> silly me! its in the first post. the mountains are one image set to infinate x, so its just one infinate row of them. i havent drawn the leaves yet, so i can work on those next.

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 1:10 am
by Hblade
Gimme the ged file and I'll help you later on ^.^ But right now I'm recording tutorials on youtube.com/Tutochao :D

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 2:10 am
by sillydraco
on youtube? ill have to watch you there :D all my stuff is here ^^

http://www.scalesnfuzz.com/Platform.zip

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 2:59 am
by Hblade
I'll fix ya up tomarow ^.^Actually, I'll do it now :D

Edit: I dont know what the heck's up with the "hills" actor my guess would be for you to redo the whole thing because I even made a new hills actor and called it a different name but something is preventing the code from working on the hills actor. It works on the clouds but not the hills it's weird dude I cant figure it out O.o

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 3:51 am
by sillydraco
aww...wait yay! erm, nope aww, them silly hills! i wonder if its because its set to infinate x? the clouds are good, theyre doin what theyre supposed to :3 ah well, ill poke them hills till they do what theyre supposed to

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 12:19 pm
by Hblade
I'll make a demo later on today showing what you need to do :D But as for your hills I've even made a new hills actor called hills2, but it did the same thing O.o

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 12:38 pm
by Hblade
Here it is ^.^ Use the arrow keys to move the view.

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 8:20 pm
by sillydraco
i did something similar so whenever i walked the hills would move too, but i ran into the problem of whenever i hit a barrier the hills would keep moving until i lifted the button :3 that looks really cool though huh? :D ive tried everything to make the hills stop when the actor stops, i tried variables, i tried if/thens, not really sure wht else to try.

Re: Need help with scenery

PostPosted: Sun Apr 11, 2010 8:44 pm
by Hblade
That's easy to fix :3 On collision with the walls - DisableMove = 1; (make the DisableMove variable :3)

On keydown with the hills,
Code: Select all
if (DisableMove == 0)
{
movement code here
}

:D

Re: Need help with scenery

PostPosted: Tue Apr 13, 2010 11:41 pm
by sillydraco
aha i got it to work :D i just made the rocks their own actor, made it so that when i collide with the rocks i stop running (and just stand still) and the hills dont do anything if my animindex is standing still (left or right).

Re: Need help with scenery

PostPosted: Wed Apr 14, 2010 12:11 am
by Hblade
Dude exellent idea :D