-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtetromino.hpp
More file actions
63 lines (44 loc) · 2.17 KB
/
Copy pathtetromino.hpp
File metadata and controls
63 lines (44 loc) · 2.17 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
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef TETROMINO_HPP
#define TETROMINO_HPP
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include "game_constants.hpp"
#include "tetris_exception.hpp"
class tetromino {
private:
const char block_symbol;
int width = 0, height = 0;
std::pair<int, int> top_point;
std::vector<std::vector<bool>> shape;
public:
explicit tetromino(const int block_symbol, const std::pair<int, int> start_point, const int start_rotation, const int shape_id);
bool checkLeft(const char (&board)[game_constants::board_width][game_constants::board_height]);
bool checkRight(const char (&board)[game_constants::board_width][game_constants::board_height]);
bool checkDown(const char (&board)[game_constants::board_width][game_constants::board_height]);
void moveLeft(char (&board)[game_constants::board_width][game_constants::board_height]);
void moveRight(char (&board)[game_constants::board_width][game_constants::board_height]);
void moveDown(char (&board)[game_constants::board_width][game_constants::board_height]);
void moveUpDebug(char (&board)[game_constants::board_width][game_constants::board_height]);
void rotate();
bool checkRotation(char (&board)[game_constants::board_width][game_constants::board_height]);
void rotateChecked(char (&board)[game_constants::board_width][game_constants::board_height]);
char getSymbol() const;
int getX() const;
int getY() const;
int getHeight() const;
int getWidth() const;
int getSingleLineWidth(int line) const;
bool checkShape(int x, int y) const;
void drawTetromino(char (&board)[game_constants::board_width][game_constants::board_height], bool clear = false);
void setBounds() {
tetromino::width = 0;
tetromino::height = shape.size();
for(int i = 0; i < tetromino::shape.size(); i++) {
if(tetromino::shape[i].size() > tetromino::width) width = tetromino::shape[i].size();
}
}
friend std::ostream& operator<<(std::ostream& os, const tetromino& t);
};
#endif