From a5e22e7398615fff450ef1404f2ab91bf2f50a2f Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 19 Mar 2019 19:09:20 -0400 Subject: fix possible issue with game over --- src/matrix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/matrix.c b/src/matrix.c index cac9c47..9602e3e 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -89,6 +89,8 @@ const vec2 basic_movements[4] = { }; void move_current(struct cetris_game* g, vec2 offset) { + if (g->game_over) return; + g->current.pos.y += offset.y; g->current.pos.x += offset.x; @@ -140,6 +142,7 @@ void hard_drop(struct cetris_game* g) { } void rotate_matrix(struct cetris_game* g, int clockwise) { + if (g->game_over) return; if (g->current.t == O) return; rstate next; @@ -245,10 +248,9 @@ void rotate_matrix(struct cetris_game* g, int clockwise) { } int8_t check_new_matrix(struct cetris_game* g, piece_matrix m) { - vec2 r; for (uint8_t x = 0; x < 4; x++) { for (uint8_t y = 0; y < 4; y++) { - r = (vec2){g->current.pos.x + x, g->current.pos.y + y}; + vec2 r = (vec2){g->current.pos.x + x, g->current.pos.y + y}; if (m[y][x]) { if (r.x > CETRIS_BOARD_X - 1 || r.x < 0) return 0; -- cgit v1.2.3-101-g0448