-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTile.cpp
100 lines (76 loc) · 2.05 KB
/
Tile.cpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "Tower.h"
#include "TowerManager.h"
#include<iostream>
using namespace std;
#include <vector>
#ifdef MACOSX
#include<GLUT/glut.h>
#else
#include<GL/glut.h>
#endif
#include<math.h>
#include<stdlib.h>
Tile::Tile(int tempX, int tempY,int newRow,int newCol){
whiteBG = new Graphic("rectangle",tempX,tempY);
whiteBG->setDimensions( 40, 40 );
whiteBG->setColor(255,255,255);
redBG = new Graphic("rectangle",tempX,tempY);
redBG->setDimensions( 40, 40 );
redBG->setColor(255,0,0);
greenBG = new Graphic("rectangle",tempX,tempY);
greenBG->setDimensions( 40, 40 );
greenBG->setColor(0,255,0);
yellowBG = new Graphic("rectangle",tempX,tempY);
yellowBG->setDimensions( 40, 40 );
yellowBG->setColor(255,255,255);
myGraphicBlack = new Graphic("rectangle",tempX,tempY);
myGraphicBlack->setDimensions( 40, 40 );
myGraphicBlack->setColor(0,0,0);
myGraphic = new Graphic("rectangle", tempX,tempY);
myGraphic->setDimensions( 36, 36 );
myGraphic->setColor(0,0,0);
myGraphicWhite = new Graphic("rectangle", tempX,tempY);
myGraphicWhite->setDimensions( 36, 36 );
myGraphicWhite->setColor(100,100,100);
myGraphicSmall = new Graphic("rectangle",tempX,tempY);
myGraphicSmall->setDimensions( 20, 20 );
row = newRow;
col = newCol;
drawMe = true;
if( (row == 13 && col != 9) || (row >= 1 && col == 0) ){//|| (row < 3 && col < 4) )
taken = true;
drawMe = false;
}
else
taken = false;
if(row == 0 && col == 0 || row == 13 && col == 9)
drawMe = false;
mouseOver = false;
//myTower = NULL;
}
void Tile::draw(){
//If we're trying to place a tower, we'll display
// either a green or red for this tower. Green
// means not set, red means set.
if(drawMe){
//we're placing a tower, draw red or green
if(TowerManager::placingTower != NULL){
if(taken)
redBG->draw();
else if(mouseOver)
yellowBG->draw();
else
greenBG->draw();
}
//we're not placing a tower, draw normally
else
whiteBG->draw();
if(mouseOver && !taken)
myGraphicWhite->draw();
else
myGraphic->draw();
}
else{
myGraphicBlack->draw();
}
}