-
Notifications
You must be signed in to change notification settings - Fork 0
/
meteorite.cpp
42 lines (38 loc) · 1 KB
/
meteorite.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
#include "meteorite.h"
Meteorite::Meteorite(GLfloat x, GLfloat y, GLfloat z)
{
setPosition(x,y,z);
setSize(SIZE,SIZE,SIZE);
quad = gluNewQuadric();
}
void Meteorite::render()
{
glPushMatrix();
glTranslatef(getPositionX(),getPositionY(),getPositionZ());
glColor4f(1.0,0.0,0.0,1.0);
gluSphere(quad, Meteorite::SIZE, 30, 30);
glPopMatrix();
//gluSphere(this->quad, Meteorite::SIZE*2, 30, 30);
}
bool Meteorite::hit(GLfloat playerX ,GLfloat playerY,GLfloat playerZ)
{
GLfloat x=getPositionX();
GLfloat y=getPositionY();
GLfloat z=getPositionZ();
if(getPositionX()<playerX)
x+=SPEED_SATELLITE;
else
x-=SPEED_SATELLITE;
if(getPositionY()<playerY)
y+=SPEED_SATELLITE;
else
y-=SPEED_SATELLITE;
if(getPositionZ()<playerZ)
z+=SPEED_SATELLITE;
else
z-=SPEED_SATELLITE;
setPosition(x,y,z);
if((int)x==(int)playerX && (int)y==(int)playerY && (int)z==(int)playerZ)
return true;
return false;
}