-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLander.cpp
More file actions
92 lines (81 loc) · 2.05 KB
/
Lander.cpp
File metadata and controls
92 lines (81 loc) · 2.05 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 "lander.h"
#define _USE_MATH_DEFINES
#include <math.h>
Lander::Lander(float x, float y, float vx, float vy, float hsize, float vsize, float angle, float spin, int maxFuel)
: object(x, y, vx, vy, hsize, vsize, angle, spin), m_thrust(0.0), m_fuel(maxFuel), m_maxFuel(maxFuel), m_burnRate(1) {
//save all relevant points to draw the lander (the points are defined
//in the object-own coordinate system)
//thruster
newPoint( 1, 0);
newPoint(-1, 0);
newPoint(-3, 5);
newPoint( 3, 5);
newPoint( 1, 0);
//fire
newPoint( 3, 5);
newPoint( 2, 5);
newPoint( 0, 5, 255, 0, 0, 255, false); // 7th point is not collidable (tip of flare)
newPoint(-2, 5, 255, 0, 0);
newPoint( 3, 5);
newPoint( 1, 0);
//stilts
newPoint(-4, 0);
newPoint(-7, 7);
newPoint(-8, 7);
newPoint(-6, 7);
newPoint(-7, 7);
newPoint(-4, 0);
newPoint( 4, 0);
newPoint( 7, 7);
newPoint( 8, 7);
newPoint( 6, 7);
newPoint( 7, 7);
newPoint( 4, 0);
//bottom
/*newPoint(-6, 0);
newPoint( 6, 0);
newPoint( 6,-2);
newPoint(-6,-2);
newPoint(-6, 0);
newPoint(-6,-2);*/
//capsula
/*newPoint(-4, -2);
newPoint( 4, -2);
newPoint( 5, -3);
newPoint( 5, -9);
newPoint( 4,-10);
newPoint(-4,-10);
newPoint(-5, -9);
newPoint(-5, -3);
newPoint(-4, -2);*/
newPoint(-4, 0);
newPoint( 4, 0);
newPoint( 5, -1);
newPoint( 5, -7);
newPoint( 4,-8);
newPoint(-4,-8);
newPoint(-5, -7);
newPoint(-5, -1);
newPoint(-4, 0);
}
void Lander::setThrust(float thr) {
m_thrust = thr;
m_fuel -= m_burnRate * thr;
if (m_fuel < 0) m_fuel = 0;
this->modifyPoint(-sin(phi()) * (5 + thr * 2), cos(phi()) * (5 + thr * 2), 7);
}
float Lander::getThrust() const {
return m_thrust;
}
void Lander::setFuel(int fuel) {
m_fuel = fuel;
}
int Lander::getFuel() const {
return m_fuel;
}
int Lander::getMaxFuel() const {
return m_maxFuel;
}
void Lander::setBurnRate(float burnRate) {
m_burnRate = burnRate;
}