I am trying to create a Space Invaders sort of game. I am using a linked list for the bullets that the player shoots and in the same list, there is also the enemies. I have a addNewEnemy Function which I run once in the main game loop. This adds lots and lots of enemies (as I expected).

How am I able to stabalise the amount of enemies being added?

Yes I have tried using Sleep(), it just made the game do everything the same but with a 2 second pause in between (I used Sleep(2000)). I have also tried using a for loop to create a delay but I just can't seem to get it to work.

Any ideas?

Thanks.

EDIT - I am using VS 2003 with DirectX

> and in the same list, there is also the enemies
This seems wrong to me.

Space invaders always looked like a 2D array, with holes in it (eventually).

You compare each bullet with every invader, and if they're in the same place at the same time, then that's a hit.

Yeah I know. It's just it draws too many on the screen. How can I control how many it draws? I have a function that adds one enemy every time I run it. If I put it in the main loop, it draws way too many.

I though you added like 8 at a time (at the top) when the whole grid of them moved down one row?

----->
     v
<-----
v

Yeah. I'm going to do it a tad different. I want to have the enemies like come randomly across the top of the screen and move down. Like Raiden. If you ever played that :P

Well if you have a fixed array, you have an upper limit to the number you create.
A new enemy can only be created after one has been shot.

Even then, the total number you create (say 3x the initial set) need to be randomly distributed over time so the player can eventually 'win' the level.

First of all, sorry for thread hijacking ;)

I too need to create a Space Invaders kind of game and I have a demo I need to copy the main features from. The invaders have to be of at least 3 different types and they change color.
So I figured the invaders are 3 child classes from a parent 'Invader' class that will have the methods of painting, moving, etc. About the post of the thread creator, what's a link list for the bullets? Should I try the same as him and create an array that will store the position of the bullets (with a maximum of maybe 40 bullets, Is there a way to dynamically allocate memory for the bullets' position as they are created so I don't have an array of 100 and use only 40 for example?)

The game will have sounds and the demo we've been given uses the sound files from the same folder the .exe is in, so they're not embedded (if that's how you would call that) or anything of that sort. The .exe is also got an icon.

We've been using PaintBox to draw stuff on application forms so I think that's how it will be this time around too.

If you wish I can attach the demo folder.

Thanks in advance

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.