Page 1 of 1

Background Depth Question:

PostPosted: Wed Apr 11, 2007 8:01 pm
by d-soldier
Heres what I want to do.. made a diagram to help you all understand, so as to clear up and misunderstanding from the words I use.
Image
Figure A represents the VIEW and my unmoving background layer. No problems here with my code.
Figure C is my foregournd which follows my player actor (though he is not cenetered in this image, ignore that) No problems here either.
Figure B is the probelm. My midground image I want to move as the actor moves, but at 50% speed, giving some depth to an unmoving background, and rapidly moving foregound. This technique is common in these kinds of games, and I'm sure the answer is an easy one, but as previously noted, I'm a graphics guy and not good with the programming (depite making text games in QBASIC when I was ten) aspects.

PostPosted: Wed Apr 11, 2007 10:40 pm
by Fuzzy
make the midground infinately tiled along the x axis. give that actor a x velocity. whenever the player steps. Same with the other layers.

The programming term you want is parallax layers.

PostPosted: Thu Apr 12, 2007 3:06 am
by d-soldier
It's not an issue of how to logically make it happen, I've already thought of several ways to do it, but as I stated, it's a lack of knowing what to code/script and where to do it. I've researched "infinite" tiling (as you stated) but cant find it within the documentation, nor playing around with the actor controls. And I cant seem to get the MidGround actor to place where I want it without giving it the x/y location of the View/Player actor, which seems to negate the effect of it moving slower then the player when he moves...

PostPosted: Thu Apr 12, 2007 4:20 am
by Fuzzy
Sorry. I failed to understand you. Here is a screen cap of the place to find infinite settings.

In the draw event for the midground actor, put this in script event

xvelocity = player.xvelocity-HowMuchSlower;

Fill in HowMuchSlower with whatever amount you want. If HowmuchSlower is greater than player.xvelocity, the midground will travel backwards. If that is a problem, you may want to try this line instead:

xvelocity = (int)player.xvelocity*0.9;

Adjust 0.9 to your tastes. what (int) does is changes a decimal number to a whole number. for example. xvelocity = (int)5*0.9; would set xvelocity to 4, dropping the 0.5 part of 4.5.

Thats it.

thanks!

PostPosted: Thu Apr 12, 2007 4:36 am
by d-soldier
Thank you very much Fuzzy! I spent over three hours working on it myself and got it working a different way, but something doesnt look right when the player jumps (cant put my finger on it yet) so I'll try your way out. I appreciate you taking the time to not only do it yourself but also screengrab/etc. for me. Thanks!