From 95a088365fc78d4a9f6625ecfdf324dbb5614dcc Mon Sep 17 00:00:00 2001 From: Oxore Date: Mon, 23 Sep 2019 02:25:43 +0300 Subject: Refactor 4: Controls Consolidate controls related variables in `controls` structure and put it into `game` structure. --- src/target/tetris.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/target') diff --git a/src/target/tetris.c b/src/target/tetris.c index e090120..d53970a 100644 --- a/src/target/tetris.c +++ b/src/target/tetris.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,16 @@ int main() .level = 1, .moveLatency = L00LATENCY, .lines = 0, + .gameTick = NULL, + .over_wait_tick = NULL, + .putTick = NULL, + .mTick = NULL, + .controls = { + .keys = 0, + .repPushDown = NULL, + .repKeyLeft = NULL, + .repKeyRight = NULL, + }, .fld = &fld, .nxt = &nxt, .texts = NULL, @@ -57,9 +68,9 @@ int main() game.over_wait_tick = sfClock_create(); game.putTick = sfClock_create(); game.mTick = sfClock_create(); - game.repPushDown = sfClock_create(); - game.repKeyLeft = sfClock_create(); - game.repKeyRight = sfClock_create(); + game.controls.repPushDown = sfClock_create(); + game.controls.repKeyLeft = sfClock_create(); + game.controls.repKeyRight = sfClock_create(); painter_load_font("dat/arial.ttf"); @@ -132,9 +143,9 @@ cleanup_load_texts: sfClock_destroy(game.over_wait_tick); sfClock_destroy(game.putTick); sfClock_destroy(game.mTick); - sfClock_destroy(game.repPushDown); - sfClock_destroy(game.repKeyLeft); - sfClock_destroy(game.repKeyRight); + sfClock_destroy(game.controls.repPushDown); + sfClock_destroy(game.controls.repKeyLeft); + sfClock_destroy(game.controls.repKeyRight); return EXIT_SUCCESS; } -- cgit v1.2.3