-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcell.cc
60 lines (49 loc) · 1.47 KB
/
cell.cc
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
#include "cell.h"
Cell::Cell() {}
Cell::Cell(int pX, int pY) : x(pX), y(pY) {
block_id = -1;
block_type = ' ';
levelCreated = -1;
filled = false;
}
Cell::Cell(int id, int pX, int pY, char pBlock_Type, int pLevelCreated, bool pFilled) : x(pX), y(pY), block_id(id),
block_type(pBlock_Type), levelCreated(pLevelCreated), filled(pFilled) {}
void Cell::setXY(int pX, int pY) {
x = pX;
y = pY;
}
Cell::~Cell(){}
std::ostream &operator<<(std::ostream &out, const Cell &c) {
//we really only care about blocktype
out << c.block_type;
return out;
}
void Cell::setCoords(int i, int j, int width, int height, Xwindow *w) {
this->i = i;
this->j = j;
this->width = width;
this->height = height;
this->w = w;
}
void Cell::draw() {
if(block_type == ' '){
w->fillRectangle(i,j,width,height,Xwindow::Black);
}else if(block_type == 'I'){
w->fillRectangle(i,j,width,height,Xwindow::Red);
}else if(block_type == 'J'){
w->fillRectangle(i,j,width,height,Xwindow::Green);
}else if(block_type == 'L'){
w->fillRectangle(i,j,width,height,Xwindow::Blue);
}else if(block_type == 'O'){
w->fillRectangle(i,j,width,height,Xwindow::Cyan);
}else if(block_type == 'Z'){
w->fillRectangle(i,j,width,height,Xwindow::Yellow);
}else if(block_type == 'S'){
w->fillRectangle(i,j,width,height,Xwindow::Magenta);
}else if(block_type == 'T'){
w->fillRectangle(i,j,width,height,Xwindow::Orange);
}
}
void Cell::undraw() {
w->fillRectangle(i,j,width,height,Xwindow::White);
}