From 50cd4a39b2f12000190b6c99fd1ad3185ea410bc Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 31 Dec 2019 00:26:31 -0500 Subject: optimize rendering --- lib/cetris.c | 8 +++++++- lib/cetris.h | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/cetris.c b/lib/cetris.c index 14c3a45..8be2b44 100644 --- a/lib/cetris.c +++ b/lib/cetris.c @@ -226,7 +226,11 @@ static void lock_current(cetris_game *g) { g->highest_line = g->current.pos.y; } - g->lock_event++; + g->lock_event.processed = false; + g->lock_event.pos = g->current.pos; + g->lock_event.t = g->current.t; + memcpy(&g->lock_event.m, &g->current.m, sizeof(piece_matrix)); + g->current.locked = true; update_board(g); } @@ -330,6 +334,8 @@ static void rotate_piece(cetris_game *g, bool clockwise) { } } + g->move_event++; + g->current.r = next; memcpy(g->current.m, &m, sizeof(piece_matrix)); update_board(g); diff --git a/lib/cetris.h b/lib/cetris.h index 3db7d37..b03f9fd 100644 --- a/lib/cetris.h +++ b/lib/cetris.h @@ -71,6 +71,13 @@ typedef struct { piece_matrix m; } tetrimino; +typedef struct { + vec2 pos; + uint8_t t; + piece_matrix m; + bool processed; +} lock_event_t; + typedef struct cetris_game cetris_game; typedef struct { @@ -146,10 +153,11 @@ struct cetris_game { // events uint8_t move_event; - uint8_t line_event; uint8_t combo_event; - uint8_t lock_event; uint8_t tetris_event; + uint8_t line_event; + + lock_event_t lock_event; // scoring flags bool tspin; -- cgit v1.2.3-101-g0448