make a start on the logic

This commit is contained in:
2024-12-03 12:05:35 +01:00
parent 8bdf6bf2d2
commit c594c94428
5 changed files with 63 additions and 6 deletions

View File

@@ -3,9 +3,20 @@
#include "../main.h"
static void add_shape(const Shape shape, Uint16* row) {
for (int i = 0; i < 4; i++) {
Uint8 rowData = (shape >> (4 * i)) & 0x0F;
if (rowData != 0)
row[4 - i] |= rowData;
}
}
// called every time the game's state is updated
void game_update(GameData game_data, const Uint8* keys) {
void game_update(GameData* game_data, const Uint8* keys) {
if (keys[SDL_SCANCODE_ESCAPE]) {
stop();
}
add_shape(TETROMINO_I, &game_data->row[4]);
}