mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 14:05:45 +01:00
fix: you need to take the square root of the size, not divide by two,
This commit is contained in:
@@ -39,12 +39,15 @@ void tmp_set_all(GameData* game_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tmp_set_random(GameData* game_data) {
|
void tmp_set_random(GameData* game_data) {
|
||||||
ShapeId id = rand() % TETROMINO_COUNT;
|
|
||||||
|
|
||||||
static int finished = 0;
|
static int finished = 0;
|
||||||
if (finished)
|
if (finished)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
finished = 1;
|
finished = 1;
|
||||||
set_shape(game_data->row, shape_from_id(id), colour_from_id(id), 1, 1);
|
for (uint8_t y = 0; y <= ROWS - SHAPE_HEIGHT; y += SHAPE_HEIGHT) {
|
||||||
|
for (uint8_t x = 0; x <= COLUMNS - SHAPE_WIDTH; x += SHAPE_WIDTH) {
|
||||||
|
const ShapeId id = (rand() % TETROMINO_COUNT) ;
|
||||||
|
set_shape(game_data->row, shape_from_id(id), colour_from_id(id), x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ enum {
|
|||||||
TETROMINO_ROTATED_270 = 24,
|
TETROMINO_ROTATED_270 = 24,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SHAPE_WIDTH ((uint8_t)(sizeof(Shape) * 8 / 2))
|
#define SHAPE_WIDTH 4
|
||||||
#define SHAPE_HEIGHT ((uint8_t)(sizeof(Shape) * 8 / 2))
|
#define SHAPE_HEIGHT 4
|
||||||
#define TETROMINO_COUNT 7
|
#define TETROMINO_COUNT 7
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user