Created
April 29, 2015 18:22
-
-
Save hawksprite/ad16bf4f02283c3a30a1 to your computer and use it in GitHub Desktop.
Asteroid Spawn 01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int maxSpawn = 30; // Every 30 milliseconds | |
int minSpawn = 1000; // Every 1000 milliseconds | |
int maxTime = 300000; // How long till we reach the maximum spawn rate, 5 minutes in milliseconds | |
DateTime born; | |
DateTime spawn; | |
void start(){ | |
born = DateTime.Now; | |
spawn = DateTime.Now; | |
} | |
void update(){ | |
int millisecondsSince = (DateTime.Now - born).TotalMilliseconds; | |
// Purportionate spawn rate off time since | |
float p = ((float)millisecondsSince / (float)maxTime) * maxSpawn; | |
if ((DateTime.Now - spawn).TotalMilliseconds >= p){ | |
spawn = DateTime.Now; | |
spawnAsteroid(); | |
} | |
} | |
void spawnAsteroid(){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment