Jump to content
  • Advertisement
Sign in to follow this  
Flawe

scrolling background

This topic is 4898 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

the title is probably wrong for this qeustion but i couldn't come up with something better... anyway, i was thinking of having a scrolling background, duh, and i want to have my spaceship in the middle of the screen att all times. now...i have big picture which serves as the background. no, my question is, how can I make the illusion of an unending universe? in other words, how can i make the ship beam through the picture so when it goes out one end, it appears at the other end? the hard part i guess is that i perhaps ahve to draw the background twice, so the user doesn't see the actual border of the picture...or?? thanx a lot for any help

Share this post


Link to post
Share on other sites
Advertisement
One repeating texture.
One quad that fit the screen.

Scroll the texture with a texture matrix. In other words, offset the s,t values on the background texture when the space ship moves. If the ship moves "right" then add a proportionate amount to the s values of all 4 vertices.

You should reset the s,t values when the texture has scrolled more than once across the screen. This will prevent them from getting too big (or small), which can cause precision issues.

Of course you need to draw the texture using REPEAT in both directions for this to work.

Share this post


Link to post
Share on other sites
What I did, was, to split a big picture (like 1024 x 1024) into smaller parts, let's say 256 x 256. See them as really big tiles. Make sure you make the entire background 'tiles' bigger than your screen, you can achieve a fast, slick smooth scroll in that way. Make sure you disable alpha blending on a large background, when it's not needed, this increases performance.

Share this post


Link to post
Share on other sites
Cool, thanx a lot guys.
I'll try your techniques and see which one I mange to implement correctly :P

Thanx

Share this post


Link to post
Share on other sites
Quote:
Original post by greldik
One repeating texture.
One quad that fit the screen.

Scroll the texture with a texture matrix. In other words, offset the s,t values on the background texture when the space ship moves. If the ship moves "right" then add a proportionate amount to the s values of all 4 vertices.

You should reset the s,t values when the texture has scrolled more than once across the screen. This will prevent them from getting too big (or small), which can cause precision issues.

Of course you need to draw the texture using REPEAT in both directions for this to work.




I implemented this technique and it really worked well..but i have a problem. Since it's a multiplayer game, i have a hard time converting the world-coordinates of the other player to screen coordinates. I compare player 1's coordinates with player 2 but it still doesn't work when i render player 2's ship because i change the s/t coordinates of the background texture all the time. that means the when i actually convert the world coordinates to screen coordinats, they are not accurate because of the background. i think...that's the other problem. i'm not really sure.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!