Member Avatar for nssltd

Hi out of personal interest i have decided to make a space invaders games. I know all the things i need to implement and i have done a good job if i do say so myself :D. But i have one final problem.
When my space ship is just staying idle i would like to the stars to draw themselves randomly and look like the space ship is traveling forward. and when i turn left i want the start to draw themselves going right so it looks like its always moving.
I know i need to create a struct and i have called it stars but im not sure how to build up this structure IE( Where it is ( X,Y) Any help is much appreciated

NSSLTD

If all the stars are to move in the same direction you could use a background image and slide it in the appropriate direction, adding a random set of stars in to the newly created empty space.

If you are looking for a 3D vanishing point effect then you will have to consider the relative distance of you ship to each star and calculate its motion. This might be better done in a Star class that contains code to adjust its position on screen relative to the motion of the ship.
You will need to maintain a collection of stars currently on screen and have some method to add new stars to the collection as others fall out of view (and out of the collection).
Also, you must paint each star to the screen as the ship moves.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.