Skip to main content
gamedev.net
🔒 Locked

Scrolling starfields

Started by starstriker1 0 replies 150+ views
Original Post
starstriker1
starstriker1
How? And how do you make it so that it seems to have multiple "layers"? I''ve seen it done, I have a few ideas for getting it done... but I''m not sure about anything. Thanks
Waverider
Waverider
If you assign a depth value to each star and divide the movement of that star by that depth value, it will provide a good simulation of stars with various depths scrolling across the screen.

In my own designs, each star has a screen position (x,y) and a depth value d.

When I want to scroll the screen by (Ux, Uy) units, each star gets this treatment:

x = x + Ux/d
y = y + Uy/d

If the (x,y) is now off the screen, I wrap the values so that the star appears on the other side.


[edited by - Waverider on January 8, 2003 7:44:03 PM]
It's not what you're taught, it's what you learn.

Topic Locked

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

Sign in to reply to this topic.