diff options
| -rw-r--r-- | src/main.c | 66 | 
1 files changed, 61 insertions, 5 deletions
| @@ -1,14 +1,70 @@  #include "raylib.h" +#define SCREEN_WIDTH  800 +#define SCREEN_HEIGHT 600 + +#define MATRIX_WIDTH  10 +#define MATRIX_HEIGHT 40 + +#define BLOCK_SIZE 25 + +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(800, 450, "raylib [core] example - basic window"); +    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()) -    { +    while (!WindowShouldClose()) {          BeginDrawing(); -        ClearBackground(RAYWHITE); -        DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); +        ClearBackground(WHITE); +        render_matrix();          EndDrawing();      } | 
