"On every game update X" in real time?

Hi. I’m trying to make a Space Invaders Clone, just to learn. I have some issues with the timing of the enemy movement at the moment. I try to use a time based movement-speed, so for every 1000ms, the speed of the movement refreshes faster, but this doesn’t seem to work? Is there any better way to call a function on a spesific time (that calls it faster over time)?

EnemyMovement

on game update every EnemySpeed will never change its interval when the value of EnemySpeed changes; it stays at the original value. Instead, try a forever loop with a pause(EnemySpeed) block after call EnemiesMovement.

As an aside, you’ll likely need a check in there somewhere to keep the EnemySpeed from getting too small or negative, either an if statement, or decrease it by a percentage value instead of a constant.

In OG Space Invaders the speed increase was due not to an intentional over time effect but because as enemies were destroyed the computer could process things just that much faster. You could try having the frequency be based on # or % of enemies remaining instead of time elapsed.

1 Like