-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTetrisBoard.h
72 lines (56 loc) · 1.5 KB
/
TetrisBoard.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Test.h - Test library for Wiring - description
Copyright (c) 2006 John Doe. All right reserved.
*/
// ensure this library description is only included once
#ifndef TetrisBoard_h
#define TetrisBoard_h
#include <OctoWS2811.h>
#define LIGHT_LEVEL 8
#define DIMX 20
#define DIMY 24
#define COLS_LEDs 60 // all of the following params need to be adjusted for screen size
#define ROWS_LEDs 36 // LED_LAYOUT assumed 0 if ROWS_LEDs > 8
#define ROWS_PER_STRIP 12
#define STRIPS ((ROWS_LEDs+ROWS_PER_STRIP-1) / ROWS_PER_STRIP)
#define LEDS_PER_STRIP (COLS_LEDs*ROWS_PER_STRIP)
const int config = WS2811_GRB | WS2811_800kHz;
// library interface description
class TetrisBoard
{
// user-accessible "public" interface
public:
TetrisBoard();
void rotTet();
void dump();
bool moveTet(int, int);
void freezeTet();
void setupGame();
bool spawn();
void gameOver();
// library-accessible "private" interface
private:
// game state
int board[DIMX][DIMY];
int _tetX, _tetY, _tetType, _tetRot, _tetColor;
// helper functions
int tetMinX();
int tetMaxX();
int tetMinY();
bool isInTet(int, int);
bool isOnBoard(int, int);
// game logic
void adjustTet();
bool tetCollide();
int lowestFullRow();
void killRow(int);
// rendering
int dimmer(int, int);
int led_map(int, int);
void setxy(int, int, uint32_t);
void paintTet(uint32_t);
void paintBlock(int, int, uint32_t);
void drawTet();
void eraseTet();
};
#endif