diff options
author | Oxore <oxore@protonmail.com> | 2019-09-23 02:25:43 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2019-09-23 02:28:25 +0300 |
commit | 95a088365fc78d4a9f6625ecfdf324dbb5614dcc (patch) | |
tree | d1c3a5408ae427844b2b3d7628879d7c79ec4a8e /src/target/tetris.c | |
parent | 7f7a7793621df7b3fdfe1578baad04cea47f3d09 (diff) |
Refactor 4: Controls
Consolidate controls related variables in `controls` structure and put
it into `game` structure.
Diffstat (limited to 'src/target/tetris.c')
-rw-r--r-- | src/target/tetris.c | 23 |
1 files changed, 17 insertions, 6 deletions
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 <SFML/System/Clock.h> #include <SFML/Graphics/RenderWindow.h> #include <stdbool.h> +#include <stdint.h> #include <stdlib.h> #include <time.h> @@ -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; } |