Allow spawn rate option to work as intended

This commit is contained in:
Tiehuis
2015-02-23 10:12:01 +13:00
parent a75c200842
commit 375cdeb7da
2 changed files with 12 additions and 4 deletions
+8
View File
@@ -183,6 +183,9 @@ void gamestate_new_block(struct gamestate *g)
srand(time(NULL));
}
/* Exit early if there are no spaces to place a block */
if (g->blocks_in_play == g->gridsize) return;
/* Fix up this random number generator */
/* Method:
* - Find a non-biased index between 0 and blocks_play, n
@@ -252,6 +255,11 @@ struct gamestate* gamestate_init(struct gameoptions *opt)
g->blocks_in_play = 0;
g->opts = opt;
/* Clamp spawn rate to maximum to avoid possible excessive calculation
* int generation of blocks */
if (g->opts->spawn_rate > g->gridsize)
g->opts->spawn_rate = g->gridsize;
highscore_load(g);
/* Initial 3 random blocks */