Skip to main content
GameDev.net gamedev.net
🔒 Locked

parallax scrolling

Started by OoMMMoO Sep 27, 2000 at 10:31 AM 0 replies 600+ views
Original Post
OoMMMoO
OoMMMoO
I posted a message a while ago about parallax scrolling and someone told me you set sections of the screen to move slower than others. But what about if I want like things in front of the slowest moving region that dont move as slow? how would I do that? you can make layers but Im not sure how can someone help?
Yanroy
Yanroy
I know a somewhat-evil way of doing parallax scrolling if you are using DD. I don''t know if there is a better way to do this that is hardwear accelerated, but just make a surface for each layer, blt your background to it or your tiles and then blt the layer. Repeat this for all the layers, going back to front, etc. Make sure to leave some transparent space in your layers to see the one''s behind. Blt your foreground objects (player, items, bad guys) last. Set up some kind of proportion that relates player movement to the speed of the background. Try this for starters, you may need/want to tweak it.

LayerSpeed = PlayerSpeed / Layer;

Make sure that Layer 1 is the one closest to the foreground and you don''t have a layer 0 . Use the LayerSpeed value to tell how much you need to offset the background layer. If you are using tiles instead of a giant bitmap you will probably need to re-render them.

I forgot to mention that the foreground objects and Layer 1 should move at the same speed, although you could change it for some rather weird effects (it reminds me of being dizzy).

If you want to have parallax scrolling for up and down as well as side to side, you can use the same formula! Just apply it to the Y coordinate instead of the X. I hope this helps you...

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming


You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.