add some temporary code for setting a random tetromino

This commit is contained in:
2025-01-27 15:32:05 +01:00
parent 7f00107c7f
commit b698a0e3d1
4 changed files with 48 additions and 3 deletions

View File

@@ -1,4 +1,7 @@
#include "placing.h"
#include <stdint.h>
#include <stdlib.h>
#include "../../window/colour.h"
#include "../game.h"
@@ -34,3 +37,41 @@ void tmp_set_all(GameData* game_data) {
set_shape(game_data->row, TETROMINO_T, COLOUR_MAGENTA, 5, 16);
}
void tmp_set_random(GameData* game_data) {
uint32_t x = rand() % TETROMINO_COUNT;
Shape shape = 0;
Colour colour = {0};
switch (x) {
case 0:
shape = TETROMINO_I;
colour = COLOUR_CYAN;
break;
case 1:
shape = TETROMINO_J;
colour = COLOUR_BLUE;
break;
case 2:
shape = TETROMINO_L;
colour = COLOUR_ORANGE;
break;
case 3:
shape = TETROMINO_O;
colour = COLOUR_YELLOW;
break;
case 4:
shape = TETROMINO_S;
colour = COLOUR_RED;
break;
case 5:
shape = TETROMINO_T;
colour = COLOUR_MAGENTA;
break;
case 6:
shape = TETROMINO_Z;
colour = COLOUR_GREEN;
break;
}
set_shape(game_data->row, shape, colour, 1, 1);
}

View File

@@ -4,7 +4,7 @@
#define SHAPE_WIDTH 4
#define SHAPE_HEIGHT 4
#define TETROMINO_COUNT 7
typedef uint16_t Shape;
enum {
// clang-format off