diff options
| author | 2019-12-31 00:26:31 -0500 | |
|---|---|---|
| committer | 2019-12-31 00:26:31 -0500 | |
| commit | 50cd4a39b2f12000190b6c99fd1ad3185ea410bc (patch) | |
| tree | 90ae6e376e1a074b1108a1f1c3fdef8d8c2f8e7a /lib | |
| parent | bfbe2af72df09c35c936241a5cdd76c3a63c3947 (diff) | |
| download | cetris-50cd4a39b2f12000190b6c99fd1ad3185ea410bc.tar.gz cetris-50cd4a39b2f12000190b6c99fd1ad3185ea410bc.tar.bz2 cetris-50cd4a39b2f12000190b6c99fd1ad3185ea410bc.zip | |
optimize rendering
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/cetris.c | 8 | ||||
| -rw-r--r-- | lib/cetris.h | 12 |
2 files changed, 17 insertions, 3 deletions
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; |