diff --git a/src/game/game.c b/src/game/game.c index bbe412a..443dcac 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -7,10 +7,12 @@ #include #include "../io/colour/colour8.h" +#include "../io/input.h" #include "../util/types.h" #include "../util/vec.h" #include "./tetromino/shapes.h" #include "tetromino/placing.h" +#include "time.h" static colour8 rowdat[COLUMNS * ROWS] = {0}; // contains the raw data of the rows, in no particular order static struct gamedata dat = {0}; @@ -63,7 +65,9 @@ struct gamedata* game_init(void) { } // called every time the game's state is updated -void game_update(int movdat) { +void game_update(int movdat, size_t time) { + static time_t drop_timeout = 0; + movdat |= !!time_poll(time, 200, &drop_timeout) * MOVD; place_update(&dat, movdat); } diff --git a/src/game/game.h b/src/game/game.h index bf272ea..67db584 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -2,6 +2,7 @@ #include #include #include +#include #include "../io/colour/colour8.h" #include "../util/types.h" @@ -37,5 +38,5 @@ struct gamedata { void next_shape(void); struct gamedata* game_init(void); -void game_update(int); +void game_update(int movdat, size_t time); void game_free(void); diff --git a/src/io/window.c b/src/io/window.c index 4c19c90..9138686 100644 --- a/src/io/window.c +++ b/src/io/window.c @@ -48,11 +48,12 @@ void window_free(void) { void window_open(void) { while (!close) { - game_update(input_getdat()); + size_t time = time_pull(); + game_update(input_getdat(), time); render_update(); static time_t timeout = 0; - if (time_poll(time_pull(), music.ms, &timeout)) + if (time_poll(time, music.ms, &timeout)) audio_play(&music); } }