# How can I make a power-up spawn system semi-random?

Basically I'm working on a similar game to achtung die kurve (http://curvefever.com). I'm almost done with the game, however I'm not completely fine with the way power up spawning works. As for now, I have setup a timer loop runs the spawn code block every 1 second. I have setup so each spawning period for each power up (total of 11 powers) is between 19.25 - 1.925 seconds. However this is fine, but it's to random I would say. For example it can be times were no power-ups spawn at all and there can be times were 5 power-ups spawn at the same time. I have made alot of games and this problem comes up every time.

• Just a thought here, not so much a criticism but a request that you give a more complete explanation of what you would like to see happen. As it stands, only people who are familiar with that game will really know what it is that you are asking, this greatly reduces the amount of people who will be able to give you a sensible response. Jun 27 '14 at 21:06
• At least include a short game play video instead of a link to their home page which doesn't have anything on the page showing what kind of game it is.
– House
Jun 27 '14 at 22:56

Why not simply spawn a random powerup every N seconds, where you specify some range to randomly pick in for N (eg. 3-10).

The power-ups will spawn out of synch. I'm not sure if you mean multiplayer-synch; if that's the case, you need to make sure your clients all use the same seed for the random number generator. That will fix your problem.

• Okey I set up now so a random power-up spawn between every 0.5 and 5.5 seconds. It works much better I would have to say. Might need to tweak the numbers though. Jun 27 '14 at 21:20
• Great, glad I could help @Freddy Jun 28 '14 at 2:21

You can make the randomness depend on how long time it was since you last spawned a power-up.

For example: Assume you want a power-up roughly every m second, with "spread" s (seconds). Here, s should be less than m.

When (m-s)+j seconds have passed since last spawned power-up, you spawn a new power-up with probability (j-1)/(2s) (or probability 1 if s=0).

This model has the following properties:

• The average time between power-ups is exactly m seconds.
• Larger s gives a higher variance in waiting time between power-ups.