summary refs log tree commit diff
diff options
context:
space:
mode:
authorturnipgod2025-03-04 15:06:42 -0500
committerturnipgod2025-03-04 15:06:42 -0500
commit6e15ecd3943acf82bd4fccfbe79cc28445deb2bc (patch)
tree6da5c87afc42fe088c9f42084384010b3ef08d10
parentfd7f9092da2cb1bc85161263b985c3f0f45e7302 (diff)
temporary rendering changes for position of game elements
-rw-r--r--src/main.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index fc42c4f..e3503a6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -76,7 +76,7 @@ int is_overlap(int x, int y)
 
 void render_matrix(void)
 {
-    int matrix_origin_x = (SCREEN_WIDTH/2 - (MATRIX_WIDTH * BLOCK_SIZE))/2;
+    int matrix_origin_x = ((SCREEN_WIDTH/2 - (MATRIX_WIDTH * BLOCK_SIZE))/2) + (BLOCK_SIZE * 5);
     int matrix_origin_y = (SCREEN_HEIGHT - MATRIX_HEIGHT/2 * BLOCK_SIZE)/2;
 
     /* draw matrix background */
@@ -147,8 +147,8 @@ void render_matrix(void)
 
     /* draw piece hold */
     draw_block(
-        SCREEN_WIDTH/2 + 1 - (BLOCK_SIZE),
-        matrix_origin_y + MATRIX_HEIGHT/2 * BLOCK_SIZE - 3 * BLOCK_SIZE,
+        matrix_origin_x - BLOCK_SIZE * 5,
+        matrix_origin_y + MATRIX_HEIGHT/2 * BLOCK_SIZE - 4 * BLOCK_SIZE,
         4*BLOCK_SIZE,
         4*BLOCK_SIZE,
         BLACK
@@ -158,9 +158,10 @@ void render_matrix(void)
             for (int j = 0; j < tetrominos[hold].size; j++) {
                 if (tetrominos[hold].directions[NORTH][j][i] == 1) {
                     draw_block(
-                        ((SCREEN_WIDTH/2 + 1 - (BLOCK_SIZE)) + (i * BLOCK_SIZE)) + 1
+                        ((matrix_origin_x - BLOCK_SIZE * 5) + (i * BLOCK_SIZE)) + 1
                                + ((hold != I && hold != O)?(BLOCK_SIZE/2):0)
-                        ,matrix_origin_y + (MATRIX_HEIGHT/2 * BLOCK_SIZE) + ((j-3) * BLOCK_SIZE)
+                        ,matrix_origin_y + (MATRIX_HEIGHT/2 * BLOCK_SIZE) + ((j-4) * BLOCK_SIZE)
+                               - ((hold == I)?BLOCK_SIZE/2:0)
                         ,BLOCK_SIZE - 2
                         ,BLOCK_SIZE - 2
                         ,tetrominos[hold].color
@@ -172,20 +173,20 @@ void render_matrix(void)
 
     /* draw piece queue */
     draw_block(
-        SCREEN_WIDTH/2 + 1 - (BLOCK_SIZE),
+        (SCREEN_WIDTH/2 + 1 - (BLOCK_SIZE)) + (BLOCK_SIZE * 4),
         matrix_origin_y + MATRIX_HEIGHT/2 * BLOCK_SIZE - 20 * BLOCK_SIZE,
         4*BLOCK_SIZE,
-        (4*BLOCK_SIZE) * 4,
+        (4*BLOCK_SIZE) * 5,
         BLACK
     );
-    for (int y = 0; y < 4; y++) {
+    for (int y = 0; y < 5; y++) {
         for (int i = 0; i < tetrominos[piece_queue[(y+current_piece_index)%14]].size; i++) {
             for (int j = 0; j < tetrominos[piece_queue[(y+current_piece_index)%14]].size; j++) {
                 if (tetrominos[piece_queue[(y+current_piece_index)%14]].directions[NORTH][j][i] == 1) {
                     draw_block(
-                        ((SCREEN_WIDTH/2 + 1 - (BLOCK_SIZE)) + (i * BLOCK_SIZE)) + 1
+                        (((SCREEN_WIDTH/2 + 1 - (BLOCK_SIZE)) + (i * BLOCK_SIZE)) + 1) + (BLOCK_SIZE * 4)
                            + ((piece_queue[(y+current_piece_index)%14] != I && piece_queue[(y+current_piece_index)%14] != O)?(BLOCK_SIZE/2):0)
-                        ,((matrix_origin_y + MATRIX_HEIGHT/2 * BLOCK_SIZE - 20 * BLOCK_SIZE) + ((j - 1) * BLOCK_SIZE)) + 1 + ((3 - y) * BLOCK_SIZE * 4) + BLOCK_SIZE/2
+                        ,((matrix_origin_y + MATRIX_HEIGHT/2 * BLOCK_SIZE - 15 * BLOCK_SIZE) + ((j - 1) * BLOCK_SIZE)) + 1 + ((3 - y) * BLOCK_SIZE * 4) - ((piece_queue[(y+current_piece_index)%14] == I)?BLOCK_SIZE/2:0)
                         ,BLOCK_SIZE - 2
                         ,BLOCK_SIZE - 2
                         ,tetrominos[piece_queue[(y+current_piece_index)%14]].color
@@ -470,6 +471,7 @@ int main(void)
 {
     srand(time(NULL));
     InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "~turnipGod's Tetris");
+    SetTargetFPS(60);
 
 
     // set default block colors
@@ -492,6 +494,7 @@ int main(void)
         BeginDrawing();
         ClearBackground(WHITE);
         render_matrix();
+        DrawFPS(0, 0);
         EndDrawing();
     }