From 9cd45c2f20be51d1033b65eb4f3ce063f233f7fe Mon Sep 17 00:00:00 2001 From: Quinn Date: Tue, 4 Feb 2025 10:34:39 +0100 Subject: [PATCH] fix: next shape is still shuffled --- src/game/game.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/game.c b/src/game/game.c index 473930a..bf2d3cf 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -13,8 +13,8 @@ #include "tetromino/placing.h" -static inline void shuffle(size_t size, ShapeId* elmnts) { - // shuffle the array using a Fisher–Yates shuffle +// shuffle the array using a Fisher–Yates shuffle +static inline void shuffle(uint8_t size, ShapeId* elmnts) { for (uint8_t i = 0; i < (size - 1); i++) { const uint8_t j = i + rand() % (size - i); const ShapeId cache = elmnts[i]; @@ -35,6 +35,9 @@ void next_shape(GameData* const game_data) { game_data->curr_idx = 0; shuffle(TETROMINO_COUNT - 1, game_data->nxt); + ShapeId cache = game_data->nxt[0]; + game_data->nxt[0] = game_data->nxt[TETROMINO_COUNT - 1]; + game_data->nxt[TETROMINO_COUNT - 1] = cache; } void game_init(GameData* const game_data) {