summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index e9eacbc..82e9e90 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,10 +35,7 @@ struct {
} current_piece;
struct Color matrix[MATRIX_WIDTH][MATRIX_HEIGHT];
-int piece_queue[TETROMINO_COUNT*2] = {
- 0, 1, 2, 3, 4, 5, 6,
- 0, 1, 2, 3, 4, 5, 6
-};
+int piece_queue[TETROMINO_COUNT*2];
int current_bag = 0;
int current_piece_index = 0;
int hold = 7;
@@ -145,6 +142,9 @@ void render_matrix(void)
void shuffle_bag(int *bag)
{
for (int i = 0; i < TETROMINO_COUNT; i++) {
+ bag[i] = i;
+ }
+ for (int i = 0; i < TETROMINO_COUNT; i++) {
int r = i + rand() / (RAND_MAX / (TETROMINO_COUNT - i) + 1);
int t = bag[r];
bag[r] = bag[i];
@@ -196,9 +196,9 @@ void handle_hold(void)
if (IsKeyDown(KEY_SPACE) && !held) {
if (hold == 7) {
hold = current_piece.type;
+ current_piece.type = piece_queue[current_piece_index];
current_piece_index++;
current_piece_index = current_piece_index % 14;
- current_piece.type = current_piece_index;
} else {
int temp = current_piece.type;
current_piece.type = hold;