-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBase.cpp
More file actions
59 lines (57 loc) · 1.18 KB
/
Base.cpp
File metadata and controls
59 lines (57 loc) · 1.18 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
#include ".\base.h"
CBase::CBase(void)
{
}
CBase::~CBase(void)
{
}
// Create the base image.
void CBase::generate()
{
for(int i = 0; i < 25; i++)
{
img[i] = true;
}
img[4] = false;
img[24] = false;
img[5] = false;
img[10] = false;
img[15] = false;
}
// Test if any of the pixels of the base have been hit.
bool CBase::testHit(Point p)
{
p.x+=1.5;
if(p.y >=50 && p.y <=50+(5*IPS))
{
for(int i = 0; i < 25; i++)
{
if(p.x >= p_pos.x+((i/5)*IPS) && p.x <= p_pos.x+((i/5)*IPS)+IPS
&& p.y >= (p_pos.y)+((i%5)*IPS) && p.y <= (p_pos.y)+((i%5)*IPS)+IPS
&& img[i] == true)
{
img[i] = false;
return true;
}
}
}
return false;
}
// Draw the base.
void CBase::drawBase()
{
glColor3f(0.9, 0.9, 0.9);
for(int i = 0; i < 25; i++)
{
if(img[i] == true)
{
glBegin(GL_POLYGON);
glVertex2i(p_pos.x+((i/5)*IPS), (p_pos.y)+((i%5)*IPS));
glVertex2i(p_pos.x+((i/5)*IPS)+IPS, (p_pos.y)+((i%5)*IPS));
glVertex2i(p_pos.x+((i/5)*IPS)+IPS, (p_pos.y)+((i%5)*IPS)+IPS);
glVertex2i(p_pos.x+((i/5)*IPS), (p_pos.y)+((i%5)*IPS)+IPS);
glVertex2i(p_pos.x+((i/5)*IPS), (p_pos.y)+((i%5)*IPS));
glEnd();
}
}
}