Jump to content
  • Advertisement
Sign in to follow this  
skuzzbag

Methods of controlling attack waves

This topic is 2113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure I understand.

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!