Archived

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

Matimeo

Starfield

Recommended Posts

Matimeo    122
I''m currently trying to make a space shooter for DOS(I''m gonna convert it to DirectX and OpenGL after I''m done). I was wondering if anyone has any ideas about how I''d go about having clouds(nebulas) randomly moving across the screen?

Share this post


Link to post
Share on other sites
LilBudyWizer    491
Side scrolling or moving towards you? Side scrolling is easiest. Just make a bitmap wider than the screen with the image. Then update the x offset into it every frame. The if you are the window width from the edge or more blit it into the back buffer. If you are less than a width away then you have to do two blits. If you want the illusion of depth then use two or more and have the "closer" ones move faster than the "further" ones.

Moving into the screen you stretch instead of scroll. You can view the bitmaps moving at a velocity. The x and y of the velocity vector gives you a quantity to add/subtract from the edges of the source rectangle. The velocity is accelerated so each frame you multiply it by an acceleration. When the source rectangle drops below the size of the screen you reset the velocity and source rectangle then start over. You can use multiple bitmaps as well. They all start their cycle with the same velocity and accelerate at the same rate. Initially they are at even intervals with the appropriate velocity at that point. The bitmap can really be as small as still looks good. The smallest star is one point so if it is 1/25th of the screen it is going to be 25 pixels at the screen. If you use at least two bitmaps then you can randomly generate the bitmap each time it resets.

Share this post


Link to post
Share on other sites