• Create Account

# Methods of controlling attack waves

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1skuzzbag  Members   -  Reputation: 120

Like
0Likes
Like

Posted 06 October 2013 - 01:59 PM

I'm creating a two stick shoot em up where there are no levels as such but a continuous stream of enemies to kill. In this type of game how do you control the release of attack waves over time?

I have an idea that I can store a list / array of times that a certain wave is triggered but I am stumped on the best way to actually achieve it.

For example if I check the array and a trigger has been reached (say 5 secs) and that triggers 50 of enemy01 to spawn what is the best way to manage that. Using something like a switch seems like it's going to get huge especially if there are 100 waves (for example).

Any ideas?

### #2Shane C  Members   -  Reputation: 727

Like
0Likes
Like

Posted 06 October 2013 - 04:52 PM

I'm not sure I understand.

Create x variable.
Release enemies x variable times.
Add an amount to x variable.

### #3GDMega6  Members   -  Reputation: 128

Like
0Likes
Like

Posted 06 October 2013 - 07:20 PM

I'm a real amateur and there's probably a better way but...

A function in the traditional math sense might be what you're looking for.

You can use one for the timer and one for each enemy.

Lets say you have a timer and when it counts down to 0 you increment a variable "wave_number". and a you randomly generated a number "difficulty" and map it between .5 and 2.

Enemy01 might have the function.  wave_number * 10 *  difficulty;

Enemy02 might have the function. (wave_number -1) * 5 * difficulty;

Enemy03 might have the function. (wave_number -2) * 3 * difficulty;

This way Enemy02 doesn't spawn in wave 1.

As long as your spawning function checks for negative values then something simple like this should work. Also don't use linear functions. That'll be very bad in later levels.

As for the function to figure out the timer for each wave, maybe a logarithmic or square root function might work. You get the idea.

### #4AngleWyrm  Members   -  Reputation: 551

Like
1Likes
Like

Posted 08 October 2013 - 07:36 PM

I have an idea that I can store a list / array of times that a certain wave is triggered but I am stumped on the best way to actually achieve it.

For example if I check the array and a trigger has been reached (say 5 secs) and that triggers 50 of enemy01 to spawn what is the best way to manage that. Using something like a switch seems like it's going to get huge especially if there are 100 waves (for example).

You could set up a Priority Queue, that has time delays for it's key, and a collection of enemy counts for it's value. Then call something like isItTimeYet() and have that pop the top value if it is time.

--"I'm not at home right now, but" = lights on, but no ones home

### #5Dragonsoulj  Crossbones+   -  Reputation: 1759

Like
0Likes
Like

Posted 09 October 2013 - 01:11 AM

You could set up a Priority Queue, that has time delays for it's key, and a collection of enemy counts for it's value. Then call something like isItTimeYet() and have that pop the top value if it is time.

That's roughly what I was thinking, although I wasn't thinking of doing key value pairs but two lists or arrays, one for triggers, in order (so 5 second wait, followed by a 10 second wait, then a 3 second wait) and the second list or array holds what enemies should be spawned, be it 50 of one enemy or 20 of one type and 30 of another. When you reach your trigger, you launch the same index/position in the other list/array, then wait for the next trigger.

Sound a lot like tower defense games.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS