diff options
| author | 2019-03-04 21:25:33 -0500 | |
|---|---|---|
| committer | 2019-03-04 21:25:33 -0500 | |
| commit | 668e2f5d2e2de68712c5939e28f24de75c6b2d0b (patch) | |
| tree | 0f9c6045a286585136092415c3d1d1acd17b9a17 | |
| parent | 8a5d8c4d909b24ccefd9e31a3ed112722aaed7d6 (diff) | |
| download | cetris-668e2f5d2e2de68712c5939e28f24de75c6b2d0b.tar.gz cetris-668e2f5d2e2de68712c5939e28f24de75c6b2d0b.tar.bz2 cetris-668e2f5d2e2de68712c5939e28f24de75c6b2d0b.zip | |
add proper drop timing based on level
| -rw-r--r-- | cetris.c | 12 | ||||
| -rw-r--r-- | cetris.h | 1 |
2 files changed, 12 insertions, 1 deletions
@@ -77,6 +77,11 @@ static const piece_matrix default_matrices[7] = { }
};
+/* LEVEL DROP SPEED VALUES */
+static const int level_drop_delay[20] = {
+ 48, 43, 38, 33, 28, 23, 18, 13, 8, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3
+};
+
/* SRS WALL KICK VALUES */
// https://tetris.wiki/SRS
@@ -303,6 +308,8 @@ void init_game(struct cetris_game* g) { #endif
g->tick = 0;
+ g->next_drop_tick = level_drop_delay[0];
+
g->current_index = 0;
clear_move_queue(g);
@@ -376,7 +383,10 @@ void shuffle_queue(struct cetris_game* g) { }
void update_game_tick(struct cetris_game* g) {
- if ((g->tick % CETRIS_HZ) == 0) move_down(g);
+ if (g->tick == g->next_drop_tick) {
+ move_down(g);
+ g->next_drop_tick = g->tick + level_drop_delay[g->level - 1];
+ }
if (g->current.lock_tick && g->current.lock_tick <= g->tick) {
g->current.pos.y++;
@@ -79,6 +79,7 @@ struct cetris_game { /* internal game tick */
int tick;
+ int next_drop_tick;
/* progress trackers */
int lines;
|