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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
#ifndef SHIP_HPP_
#define SHIP_HPP_
/*
* Author: jrahm
* created: 2013/10/31
* Ship.hpp: <description>
*/
#include "glox/GloxLookAtPerspective.hpp"
#include "glox/GloxPoint.hpp"
#include "glox/GloxVector3.hpp"
#include "slox/events/SloxKeyListener.hpp"
#include "ControlMotionListener.hpp"
#include "sons_of_sol/Projectile.hpp"
#include <queue>
#include <vector>
#define GUN_RATE 1
#define N_LIVING_PROJECTILES (TTL / GUN_RATE)
/* This is a class
* for the first person
* ship */
class PlayerShip : public ControlMotionListener {
public:
inline PlayerShip()
: m_forward(0, 0, -1),
m_up(0, 1, 0),
m_right(1, 0, 0),
m_dpitch(0),
m_dyaw(0),
m_droll(0),
m_droll_to(0),
m_dforward(0),
m_dforward_to(0),
m_dup(0),
m_dup_to(0),
m_dright(0),
m_dright_to(0),
m_jitter(0),
m_is_firing(false) {}
/* Draw the heads-up-display of the
* ship */
void drawHUD();
/* Render the perspective of
* this ship */
void renderPerspective();
/* Move the ship up and down */
void pitch(float angle);
/* Roll the ship */
void roll(float angle);
/* Rotate the ship side to side */
void yaw(float angle);
/* Update this object */
void update();
const glox::GloxStandardProjection& getPerspective() const {
return m_perspective;
}
glox::GloxStandardProjection& getPerspective() { return m_perspective; }
void setPerspective(const glox::GloxLookAtPerspective& perspective) {
m_perspective = perspective;
}
inline void setDPitch(float dpitch) { this->m_dpitch = dpitch; }
inline void setDRoll(float droll) { this->m_droll = droll; }
inline void setDYaw(float dyaw) { this->m_dyaw = dyaw; }
inline float getDPitch() const { return m_dpitch; }
inline float getDYaw() const { return m_dyaw; }
inline float getDRoll() const { return m_droll; }
inline void setDForwardTo(float dforward) { m_dforward_to = dforward; }
inline float getDForward() { return m_dforward; }
virtual void onControlMotion(const ControlMotionEvent& evt);
inline const glox::GloxPoint<> getPosition() const { return m_position; }
inline void setPosition(const glox::GloxPoint<>& pos) { m_position = pos; }
inline void setJitter(float jitter) { m_jitter = jitter; }
inline float getJitter() { return m_jitter; }
void drawProjectiles();
private:
/* The position of the ship */
glox::GloxPoint<> m_position;
/* The orientation of the ship */
glox::GloxVector3<> m_forward;
glox::GloxVector3<> m_up;
glox::GloxVector3<> m_right;
/* The perspective of the ship */
glox::GloxLookAtPerspective m_perspective;
float m_dpitch;
float m_dyaw;
float m_droll;
float m_droll_to;
float m_dforward;
float m_dforward_to;
float m_dup;
float m_dup_to;
float m_dright;
float m_dright_to;
float m_jitter;
bool m_is_firing;
std::vector<Projectile> m_living_projectiles;
std::queue<int> m_open_positions;
};
#endif /* SHIP_HPP_ */
|