summaryrefslogtreecommitdiff
path: root/src/engine.c
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2019-09-23 01:11:58 +0300
committerOxore <oxore@protonmail.com>2019-09-23 01:23:51 +0300
commit7f7a7793621df7b3fdfe1578baad04cea47f3d09 (patch)
tree2e62a6dadcfb925963ceb959fc5916fbd92e91d8 /src/engine.c
parent6bda286861dfd818f3d71c9a75a9c5e40923cdf8 (diff)
Refactor 3: unwrap and remove signal_harddrop
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/engine.c b/src/engine.c
index 16daf4f..7ab9705 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -391,20 +391,6 @@ static void signal_up(struct game *game)
sfClock_restart(game->putTick);
}
-static void signal_harddrop(struct game *game)
-{
- struct field *fld = game->fld;
-
- while (field_move_shape_down(fld, 1))
- game->scoreCurrent++;
- if (field_shape_out_of_bounds(fld, &fld->shape[ACTIVE_SHAPE_INDEX]))
- transition_game_over_wait(game);
- else
- transition_put_shape(game);
- sfClock_restart(game->gameTick);
- sfClock_restart(game->putTick);
-}
-
static void signal_down(struct game *game)
{
struct field *fld = game->fld;
@@ -656,7 +642,18 @@ static int game_loop(struct game *game)
}
if (ret_keys & HARDDROP) {
- signal_harddrop(game);
+ struct field *fld = game->fld;
+
+ while (field_move_shape_down(fld, 1))
+ game->scoreCurrent++;
+
+ sfClock_restart(game->gameTick);
+ sfClock_restart(game->putTick);
+
+ if (field_shape_out_of_bounds(fld, &fld->shape[ACTIVE_SHAPE_INDEX]))
+ return GAME_LOOP_GAME_OVER;
+ else
+ transition_put_shape(game);
}
if (ret_keys & LEFT) {