-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.cpp
More file actions
88 lines (77 loc) · 2.24 KB
/
block.cpp
File metadata and controls
88 lines (77 loc) · 2.24 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
#include "block.h"
Block::Block ()
{
}
Block::~Block ()
{
}
void Block::Draw ()
{
DrawAt (_posXY);
}
void Block::DrawAt (wcPt2D posXY)
{
glLoadIdentity ();
glTranslatef (0, 0, -1.0f);
switch (BlockType)
{
case Blank:
glColor3f (1, 1, 1);
glBegin (GL_POLYGON);
glVertex2f (posXY.x, posXY.y);
glVertex2f (posXY.x + getSizeX (), posXY.y);
glVertex2f (posXY.x + getSizeX (), posXY.y - getSizeY ());
glVertex2f (posXY.x, posXY.y - getSizeY ());
glEnd ();
break;
case Filled:
glColor3f (0, 0, 0);
glBegin (GL_POLYGON);
glVertex2f (posXY.x, posXY.y);
glVertex2f (posXY.x + getSizeX (), posXY.y);
glVertex2f (posXY.x + getSizeX (), posXY.y - getSizeY ());
glVertex2f (posXY.x, posXY.y - getSizeY ());
glEnd ();
glColor3f (1, 1, 0);
glBegin (GL_POLYGON);
glVertex2f (posXY.x + .00125f * 3, posXY.y - .0016f * 3);
glVertex2f (posXY.x + getSizeX () - .00125f * 3, posXY.y - .0016f * 3);
glVertex2f (posXY.x + getSizeX () - .00125f * 3, posXY.y - getSizeY () + .0016f * 3);
glVertex2f (posXY.x + .00125f * 3, posXY.y - getSizeY () + .0016f * 3);
glEnd ();
glColor3f (0, 0, 0);
glBegin (GL_POLYGON);
glVertex2f (posXY.x + .00125f * 3 * 5, posXY.y - .0016f * 3 * 5);
glVertex2f (posXY.x + getSizeX () - .00125f * 3 * 5, posXY.y - .0016f * 3 * 5);
glVertex2f (posXY.x + getSizeX () - .00125f * 3 * 5, posXY.y - getSizeY () + .0016f * 3 * 5);
glVertex2f (posXY.x + .00125f * 3 * 5, posXY.y - getSizeY () + .0016f * 3 * 5);
glEnd ();
glColor3f (1, 0, 0);
glBegin (GL_POLYGON);
glVertex2f (posXY.x + .00125f * 3 * 6, posXY.y - .0016f * 3 * 6);
glVertex2f (posXY.x + getSizeX () - .00125f * 3 * 6, posXY.y - .0016f * 3 * 6);
glVertex2f (posXY.x + getSizeX () - .00125f * 3 * 6, posXY.y - getSizeY () + .0016f * 3 * 6);
glVertex2f (posXY.x + .00125f * 3 * 6, posXY.y - getSizeY () + .0016f * 3 * 6);
glEnd ();
break;
case Transparent:
break;
}
}
float Block::getSizeX ()
{
return 2 * 30.0f / 800.0f;
}
float Block::getSizeY ()
{
return 2 * 30.0f / 600.0f;
}
void Block::setPosXY (wcPt2D PosXY)
{
_posXY.x = PosXY.x;
_posXY.y = PosXY.y;
}
void Block::setBlockType (BlockTypes type)
{
BlockType = type;
}