-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShip.h
101 lines (74 loc) · 2.11 KB
/
Ship.h
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
#ifndef SHIP_H
#define SHIP_H
#include "GLHeader.h"
#include <Box2D/Box2D.h>
#include <vector>
#include <deque>
#include "Bullet.h"
#include "Vortex.h"
#include "ShipIntf.h"
#include "DestroyableIntf.h"
#include "Explosion.h"
#define RAD2DEG(x) ((x) * 57.2957795f)
class Ship : public ShipIntf, public DestroyableIntf
{
struct TempStruct
{
GLfloat vertices[4];
GLfloat colors[4];
};
public:
//Default constructor
Ship(b2World& world);
~Ship();
//The function that actually puts the object on the screen
void Draw();
//called every frame before drawing to do whatever was commanded
//in ProcessInput()
void DoCommands();
//turn a bit mapped field into a set of commands to be handled
//during DoCommands
void ProcessInput(int commands);
void AddBullet(Bullet* pBullet);
//override of DestroyableIntf function
virtual void DestroyObject();
private:
static const glm::mat4 m_projMat;
glm::vec3 m_rotateAxis;
//only using 1 vertex buffer for this object
GLuint m_vertexBufferHandleArray[1];
GLuint m_colorBufferHandleArray[1];
static GLuint m_shaderProgram;
static uint32 m_soundIndex;
static bool m_bSoundLoaded;
GLuint m_indexBuffer;
GLuint m_numIndices;
GLfloat m_angle;
//Box2D parameters
//reference to the world to use for Box
b2World& m_worldRef;
//should destroy this body in the destructor
b2Body *m_pBody;
//ship creation stuff
int m_index;
int m_hitCount;
static int index;
//Flags to indicate button states
bool m_bForceCCW; //left
bool m_bForceCW; //right
bool m_bForceForward; // Forward thrust
Bullet m_bullet1;
Bullet m_bullet2;
Bullet m_bullet3;
std::deque<Bullet*> m_bullets;
float m_startX;
float m_startY;
Vortex m_vortex;
Explosion m_explosion;
//Container to hold the interface to pass to
//Box2D as UserData, since it's stores it as a void
//and will lose most of its vtable
DestroyableIntfContainer m_destroyableContainer;
void respawn();
};
#endif //SHIP_H