-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.c
More file actions
50 lines (41 loc) · 1.28 KB
/
debug.c
File metadata and controls
50 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <string.h>
#include "bool.h"
#include "input_utils.h"
#include "grid.h"
#include "tetromino.h"
// Runs debug mode, allowing the user to drop tetrominos onto a grid
void debugMode()
{
char grid[GRID_HEIGHT][GRID_WIDTH];
int gridColumnHeights[GRID_WIDTH];
char tet;
int droppedColumn;
int rotation;
char input;
memset(grid, '_', sizeof(grid));
memset(gridColumnHeights, 0, sizeof(gridColumnHeights));
printGrid(grid);
while (TRUE)
{
tet = getTetrominoToDrop();
rotation = getRotation(tet);
droppedColumn = getColumnToDropIn(getTetromino(tet, rotation)->Width);
if (dropTetrominoToGrid(getTetromino(tet, rotation), droppedColumn, grid, gridColumnHeights) == FALSE)
printf("Not enough space! Clear the grid or try another tetromino/column\n\n");
else printGrid(grid);
input = getDebugMenuInput();
switch(input)
{
case '1':
break;
case '2':
memset(grid, '_', sizeof(grid));
memset(gridColumnHeights, 0, sizeof(gridColumnHeights));
printGrid(grid);
break;
case '3':
return;
}
}
}