summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cetris.c8
-rw-r--r--lib/cetris.h12
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;