-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShell.cpp
More file actions
92 lines (63 loc) · 1.66 KB
/
Shell.cpp
File metadata and controls
92 lines (63 loc) · 1.66 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
#include "stdafx.h"
#include "Shell.h"
//#include <GL/glut.h>
#include <math.h>
#define PI 3.14159
//---------------------------------------------------------------------
//---------------------------------------------------------------------
GLUquadricObj *shell;
int Shell::count = 0;
void Shell::init(GLfloat xLoc, GLfloat yLoc, GLfloat zLoc, GLfloat heading) {
id = count++;
x = xLoc;
y = yLoc;
z = zLoc;
azimuth = heading;
realX = (GLfloat) (x - cos(azimuth * PI/180.0f) + 7.5f * sin(azimuth * PI/180.0f));
realZ = (GLfloat) (z - sin(azimuth * PI/180.0f) - 7.5f * cos(azimuth * PI/180.0f));
range = 0;
damage = 25;
shell = gluNewQuadric();
ShellList = glGenLists(1);
glNewList(ShellList, GL_COMPILE);
glColor3f(0.0, 0.0, 0.0);
gluSphere(shell, 0.25, 6, 6);
glEndList();
} // end init
void Shell::draw() {
glCallList(ShellList);
} // end draw
int Shell::getID() {
return id;
} // end getID
GLfloat Shell::getX() {
return x;
} // end getX
GLfloat Shell::getY() {
return y;
} // end getX
GLfloat Shell::getZ() {
return z;
} // end getX
GLfloat Shell::getAzimuth() {
return azimuth;
} // end getX
GLfloat Shell::getRange() {
return range;
} // end getRange
void Shell::updateRealPosition() {
realX += (GLfloat) (FACTOR * sin(azimuth * PI/180.0f));
realZ -= (GLfloat) (FACTOR * cos(azimuth * PI/180.0f));
} // end updateRealPosition
void Shell::increaseRange() {
range += FACTOR;
} // end increaseRange
GLfloat Shell::getRealX() {
return realX;
} // end getRealX
GLfloat Shell::getRealZ() {
return realZ;
} // end getRealZ
GLfloat Shell::getDamage() {
return damage;
} // end getDamage