1
0
Fork 0
tetris-c/include/grid.h
2026-05-10 00:20:28 +02:00

25 lines
582 B
C

#ifndef __GRID_H
#define __GRID_H
#include <stdint.h>
#include <sys/types.h>
#define GRID_WIDTH 10
#define GRID_HEIGHT 16
#define grid_cell(grid, x, y) ((grid)[(x) + ((y) * GRID_WIDTH)])
typedef uint8_t grid_t[GRID_HEIGHT * GRID_WIDTH];
void grid_init(grid_t grid);
int grid_check_collision(grid_t grid, int8_t x, int8_t y);
// clears all full rows on the board.
// Returns the number of rows cleared.
uint32_t grid_clear_full_rows(grid_t grid);
// Clears the row and moves all rows above down one step.
void grid_clear_row(grid_t grid, uint8_t row);
#endif /* __GRID_H */