diff options
| -rw-r--r-- | .cache/clangd/index/TETRIS.c.EC74E3FB69CEE55B.idx | bin | 4270 -> 4526 bytes | |||
| -rw-r--r-- | TETRIS.c | 26 | ||||
| -rwxr-xr-x | tetris | bin | 51576 -> 51672 bytes |
3 files changed, 24 insertions, 2 deletions
diff --git a/.cache/clangd/index/TETRIS.c.EC74E3FB69CEE55B.idx b/.cache/clangd/index/TETRIS.c.EC74E3FB69CEE55B.idx Binary files differindex 679cba0..5742a7a 100644 --- a/.cache/clangd/index/TETRIS.c.EC74E3FB69CEE55B.idx +++ b/.cache/clangd/index/TETRIS.c.EC74E3FB69CEE55B.idx @@ -205,7 +205,7 @@ void SAVE_TETROMINO(TETROMINO *tetromino, int **GRID) { int GRIDX = tetromino->x + x; int GRIDY = tetromino->y + y; - if (GRIDX <= COLUMNS && GRIDY >= 0 && GRIDY <= ROWS - 2) + if (GRIDX < COLUMNS && GRIDY >= 0 && GRIDY < ROWS) GRID[GRIDY][GRIDX] = 1; } } @@ -219,7 +219,7 @@ void DRAW_SAVED_TETROMINO(int **GRID, TETROMINO *tetromino) for (int x = 0; x < COLUMNS; x++) { if (GRID[y][x] == 1) - DrawRectangle(x * CELL_WIDTH, y * CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT, tetromino->color); + DrawRectangle((x * CELL_WIDTH) , (y * CELL_HEIGHT) , CELL_WIDTH, CELL_HEIGHT, tetromino->color); } } } @@ -237,6 +237,27 @@ void DRAW_STATS(TETROMINO *tetromino) DrawText(CURRENT_X_POSITION, 10, 50, FONT_SIZE, BLUE); } +void CHECK_FULL_LINE(int **GRID) +{ + int LAST_LINE_Y = ROWS - 2; + bool FULL_LINE = true; + + for (int x = 0; x <= COLUMNS; x++) + { + if (GRID[LAST_LINE_Y][x] == 0) + { + FULL_LINE = false; + } + + } + if (!FULL_LINE){ + for (int x = 0; x <= COLUMNS; x++) + { + GRID[LAST_LINE_Y][x] = GRID[LAST_LINE_Y][0]; + } + } +} + int main() { InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Tetris"); @@ -246,6 +267,7 @@ int main() int **GRID = CREATE_TETROMINOS_GRID(ROWS, COLUMNS); if (!GRID) { + printf("FAILED TO ALLOCATE MEMORY FOR THE GRID"); CloseWindow(); return 1; } Binary files differ |
