summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-11-01 18:43:00 -0400
committerAndrew Opalach <andrew@akon.city> 2019-11-01 18:43:00 -0400
commit6fa128565abbe31c6610699273762fd1a2555194 (patch)
tree73d4f0c94b9189cc28913ee0719939c1fd52470c /lib
parent9f4130dde0a0ea9a036fccdbb30ae2644daae9a4 (diff)
downloadcetris-6fa128565abbe31c6610699273762fd1a2555194.tar.gz
cetris-6fa128565abbe31c6610699273762fd1a2555194.tar.bz2
cetris-6fa128565abbe31c6610699273762fd1a2555194.zip
add move sound
Diffstat (limited to 'lib')
-rw-r--r--lib/cetris.c2
-rw-r--r--lib/cetris.h3
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/cetris.c b/lib/cetris.c
index 3751157..ea53576 100644
--- a/lib/cetris.c
+++ b/lib/cetris.c
@@ -167,6 +167,7 @@ static void move_current(cetris_game *g, uint8_t move) {
g->current.pos.x += basic_movements[move].x;
int check = check_matrix(g, &g->current.m);
+ if (check > 0 && move != DOWN) g->move_event++;
if (check <= 0) {
g->current.pos.y -= basic_movements[move].y;
g->current.pos.x -= basic_movements[move].x;
@@ -530,6 +531,7 @@ CETRIS_EXPORT bool update_game_tick(cetris_game *g) {
bool did_move = false;
if (g->next_drop_tick && g->tick >= g->next_drop_tick) {
+ if (g->held_moves[DOWN]) g->move_event++;
move_current(g, DOWN);
g->next_drop_tick = 0;
did_move = true;
diff --git a/lib/cetris.h b/lib/cetris.h
index 0cbc5c3..1c3d8f0 100644
--- a/lib/cetris.h
+++ b/lib/cetris.h
@@ -144,7 +144,8 @@ struct cetris_game {
uint8_t line_combo;
bool game_over;
- // events
+ // events
+ uint8_t move_event;
uint8_t line_event;
uint8_t lock_event;
uint8_t tetris_event;