-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.h
More file actions
115 lines (93 loc) · 2.71 KB
/
Block.h
File metadata and controls
115 lines (93 loc) · 2.71 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef ABSTRACTBLOCK_H_
#define ABSTRACTBLOCK_H_
#include <iostream> //NOTE: REMOVE
#include "Vector4.h"
#include "Matrix44.h"
#include "Cube.h"
/**
* @brief This class describes the interface for all blocks in the game.
*/
class Block
{
private:
bool touched;
const GLfloat size;
Matrix44 globalOrientation; //NOTE: REMOVE
Cube model;
bool isPenatrable;
public:
Block(bool isPenatrable, GLfloat size = 1.0, const Matrix44& globalOrientation = Matrix44()) : isPenatrable(isPenatrable), touched(false), size(size), globalOrientation(globalOrientation), model(this -> size, globalOrientation)
{
if (isPenatrable) {
setColor(Vector4(0.5, 0.0, 1.0, 1.0));
}
else {
setColor(Vector4(1.0, 1.0, 1.0, 1.0));
}
}
/**
* Sets the state of the block to "touched"
*/
void touch()
{
touched = true;
if (isPenatrable) {
setColor(Vector4(1.0, 0.5, 0.0, 1.0));
}
}
/**
* @return true if the block has been touched
*/
bool hasBeenTouched() const { return touched; }
/**
* @return true if the block is an obstacle
*/
bool isImpenetrable() {
return !isPenatrable;
}
/**
* Draws the block
*/
void draw() const { model.draw(); }
/**
* Draws a "Shadow Volume" for use with the stenciled shadow volume algorithm
* @param lightPosition the light source which determines how edges are extruded to form the shadow volume
*/
void drawShadowVolume(const Vector4& lightPosition) const { model.drawShadowVolume(lightPosition); }
/**
* @return A Vector4 containing the x, y, and z coordinates of the block with respect to the standard basis
*/
/*const Vector4 getLocation() const
{
//NOTE: Need to do a change of basis to the standard basis
return Vector4();
}*/
/**
* @return the block's Modelview transformation
*/
const Matrix44& getOrientation() const { return model.getOrientation(); }
/**
* @return the size of the block
*/
const GLfloat& getSize() const { return size; }
/**
* Sets the block's color for when it is drawn
* @see draw
* @param color a vector containing the red, green, blue, and alpha components of the color
*/
void setColor(const Vector4& color) { model.setColor(color); }
/*virtual bool equals (const AbstractBlock& other) const
{
std::cout << "AbstractBlock::equals" << endl;
return size == other.size;
}
friend bool operator == (const AbstractBlock& lhs, const AbstractBlock& rhs)
{
return lhs.equals(rhs);
}
friend bool operator != (const AbstractBlock& lhs, const AbstractBlock& rhs)
{
return !(lhs == rhs);
}*/
};
#endif /*ABSTRACTBLOCK_H_*/