943,804 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 799
  • C++ RSS
Dec 13th, 2007
0

Linked List Issue

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Oblique is offline Offline
6 posts
since Sep 2007
Dec 13th, 2007
0

Re: Linked List Issue

> 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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Dec 13th, 2007
0

Re: Linked List Issue

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Oblique is offline Offline
6 posts
since Sep 2007
Dec 13th, 2007
0

Re: Linked List Issue

I though you added like 8 at a time (at the top) when the whole grid of them moved down one row?
C++ Syntax (Toggle Plain Text)
  1. ----->
  2. v
  3. <-----
  4. v
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Dec 13th, 2007
0

Re: Linked List Issue

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Oblique is offline Offline
6 posts
since Sep 2007
Dec 13th, 2007
0

Re: Linked List Issue

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Nov 20th, 2008
0

Re: Linked List Issue

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
Reputation Points: 10
Solved Threads: 4
Light Poster
emotionalone is offline Offline
33 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Discrete solution help!
Next Thread in C++ Forum Timeline: New to C++ Few Questiond





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC