#include "raylib.h" #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 #define MATRIX_WIDTH 10 #define MATRIX_HEIGHT 40 #define BLOCK_SIZE 25 #include "tetromino.h" struct Color matrix[MATRIX_WIDTH][MATRIX_HEIGHT]; void render_matrix(void); void render_matrix(void) { /* top left corner */ int matrix_start_x = (SCREEN_WIDTH/2 - (MATRIX_WIDTH * BLOCK_SIZE)) / 2; int matrix_start_y = (SCREEN_HEIGHT - (3 * MATRIX_HEIGHT / 2 * BLOCK_SIZE)) / 2; /* draw matrix background */ DrawRectangle( matrix_start_x - 1 ,matrix_start_y + (MATRIX_HEIGHT/2 * BLOCK_SIZE) - 1 ,MATRIX_WIDTH * BLOCK_SIZE + 2 ,MATRIX_HEIGHT/2 * BLOCK_SIZE + 2 ,GRAY ); /* draw blocks from matrix */ for (int y = 0; y < 40; y++) { for (int x = 0; x < 10; x++) { DrawRectangle( (x * BLOCK_SIZE) + matrix_start_x + 1 ,(y * BLOCK_SIZE) + matrix_start_y + 1 ,BLOCK_SIZE - 2 ,BLOCK_SIZE - 2 ,matrix[x][y] ); } } } int main(void) { InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "~turnipGod's Tetris"); // set all blocks to white for (int y = 0; y < 40; y++) { for (int x = 0; x < 10; x++) { matrix[x][y] = WHITE; } } // set playarea blocks to purple for (int y = 20; y < 40; y++) { for (int x = 0; x < 10; x++) { matrix[x][y] = PURPLE; } } while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(WHITE); render_matrix(); EndDrawing(); } CloseWindow(); return 0; }