Linked List Issue

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 6
Reputation: Oblique is an unknown quantity at this point 
Solved Threads: 0
Oblique Oblique is offline Offline
Newbie Poster

Linked List Issue

 
0
  #1
Dec 13th, 2007
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
Last edited by Oblique; Dec 13th, 2007 at 1:04 am. Reason: put in my compiler.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Linked List Issue

 
0
  #2
Dec 13th, 2007
> 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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 6
Reputation: Oblique is an unknown quantity at this point 
Solved Threads: 0
Oblique Oblique is offline Offline
Newbie Poster

Re: Linked List Issue

 
0
  #3
Dec 13th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Linked List Issue

 
0
  #4
Dec 13th, 2007
I though you added like 8 at a time (at the top) when the whole grid of them moved down one row?
  1. ----->
  2. v
  3. <-----
  4. v
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 6
Reputation: Oblique is an unknown quantity at this point 
Solved Threads: 0
Oblique Oblique is offline Offline
Newbie Poster

Re: Linked List Issue

 
0
  #5
Dec 13th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Linked List Issue

 
0
  #6
Dec 13th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 32
Reputation: emotionalone is an unknown quantity at this point 
Solved Threads: 4
emotionalone emotionalone is offline Offline
Light Poster

Re: Linked List Issue

 
0
  #7
Nov 20th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC