Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6351 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone knows any good tutorial or book on Parallax scrolling (or any other scrolling techniques)? And about 2D scrolling in OPENGL?

Share this post

Link to post
Share on other sites
Parallax scrolling is fairly easy. If you can make a single layer scroll your already half way there.

So let''s do it like this 3 layers.

Background Layer
Middle Layer
Foreground Layer.

Now let''s say your player moves at a velocity of 3. This means that if your player is moving that you probably want to scroll your foreground layer at a velocity of 3 also.

Now what parallax introduces is the faking of 3d in a 2d world. When in the passengers seat of a car, driving down the highway the closer things are to you the faster they move.

So in order to do this with our layers. We take the velocity of the foreground layer (3 in our case). And we reduce it for the middle layer. In this case I want to take the speed of the foreground layer and reduce it by 25%. 3 * .25 = .75 so 3 - 0.75 = 2.25. 2.25 is the new velocity for our middle layer.
Finaly the background layer. We take our middle layers velocity and reduce that by 25%. 2.25 * .25 = .5625 so 2.25 - .5625 = 1.6875. Or rounded up to 1.7. So 1.7 is our new background layers velocity.

So now what do you do?

Well check if the player is moving. If he''s moving right, increase the foreground position by it''s velocity which is 3, the middle layers position by it''s velocity which is 2.25, and the backgrounds position by it''s velocity which is 1.7.

If he;s moving left, you decrease the position by the velocity and bam! you''ve got parallax scrolling.

Share this post

Link to post
Share on other sites
Wow, thanks evaclear. I''ll give it a try.

Do you know opengl? So in order to do this in opengl, i''d use
something like glRasterPos21 an GlBitmap, or GLDrawPixels, right?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!