-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathharmony-design.txt
executable file
·268 lines (209 loc) · 5.75 KB
/
harmony-design.txt
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
// Harmony
// TODO: Paint in the texture a closed door for the bomb to fall.
// What are the important details for the models?
// Night mode, mini map, propellers, projectiles, move cannon with mouse, enemies, collision, reset, "random" movement,
// The user can control the cannon direction with the mouse.
// There are two axis of rotation that are controlled by the mouse.
// When the airplane dies, there is a screen with dead or alive
==============================
Main
------------------------------
// All of the bullets that aren't dead are saved to continue moving through space.
bullets: a queue of bullets that when a bullet dies, it is removed from it.
collect memory garbage
------------------------------
display()
IF player is dead THEN
draw "You lost" on the middle of screen
ELSE IF player won THEN
draw "You win" on the middle of screen
draw current score on top-right of the window
FOR EACH projectile
projectile.draw()
------------------------------
addResetListener(ResetListener): void
------------------------------
reset()
FOR EACH reset listener
listener.reset()
remove all projectiles // bombs and bullets
------------------------------
idle()
// detect collision of each projectile with an obstacle
FOR EACH projectile
move projectile
IF projectile is dead THEN
remove projectile from queue
remove all projectiles that died
// make random movements for each enemy
FOR EACH enemy
compute enemy next position
==============================
// *** Airstrip ***
// The airstrip has light points on each side of it and there are painting
// tracks at each side as well. The airstrip though is constructed with a
// line that comes from the SVG file and must be converted to an actual
// airstrip. The width of the player influences the width of the airstrip,
// but the airstrip considers that the width is already fixed.
==============================
Airstrip
------------------------------
// The line is used to know the start and end of the airstrip, while the
// width is used to know the sideways of the airstrip. This is twice the
// airplane diameter.
Airstrip(line, width)
------------------------------
setStripes(count)
------------------------------
draw()
draw light
get current light position
put a light at left and right of the sides
draw ground
load black texture
draw stripes
load white texture
------------------------------
through time()
get time elaspsed since last call
IF accumulated time + elapsed time > time interval of each stripe THEN
next stripe
accumulate elapsed time
next stripe()
IF last stripe THEN
set as first stripe
ELSE
set as stripe + 1
==============================
// *** Cannon ***
==============================
Cannon
------------------------------
static
load cannon model
------------------------------
getExit()
return offset + direction * cannon length
getDirection()
// use the same algorithm as the others
r = cos(vertical)
x = r * cos(horizontal)
y = r * sin(horizontal)
z = sin(vertical)
return <x, y, z>
==============================
==============================
Player
------------------------------
fire()
get cannon position
get cannon direction
get airplane velocity
create bullet
attach to Game the bullet as projectile
bomb()
get door position
get airplane velocity xy
create bomb
attach to Game the bomb as projectile
==============================
// *** Map ***
==============================
MapItem: interface
------------------------------
drawMap(): void
==============================
// subclasses that implements MapItem: Airplane, Arena, Tank, Airstrip
// *** Firing with the gun, bomb ***
/**
* A class that keeps track of all projectiles and hadling collision between the
* projectiles and obstacles. Both projectiles and obstacles can be added.
*/
==============================
projectile_manager_t
------------------------------
/**
* Obstacles that cannot die, but can stop a projectile.
*/
inanimate obstacles
/**
* Obstacles that can die and stops a projectile.
*/
animated obstacles
------------------------------
projectiles: a list of projectiles
------------------------------
addObstacles(obs, animated)
addProjectile(p)
------------------------------
update(millis)
==============================
==============================
bullet: projectile
------------------------------
enemy: bool
------------------------------
onRun()
IF is from an enemy THEN
IF the bullet hit the player THEN
kill the bullet
kill the player
ELSE
IF bullet hit an enemy THEN
kill the bullet
kill the enemy
score
==============================
// A sphere used for collision.
==============================
Obstacle
------------------------------
overlaps(sphere)
==============================
==============================
Bomb: projectile
------------------------------
acceleration z
------------------------------
Bomb()
static
load bomb model
------------------------------
onRun()
IF hit an obstacle
remove bomb
if the obstacle is an enemy
kill it
ELSE
update velocity at z axis
------------------------------
draw(): void
uses the bomb model
==============================
==============================
projectile
------------------------------
position
velocity
------------------------------
accumulated time
------------------------------
dead: bool
------------------------------
transformAndDraw(): void
draw(): void, abstract
IF alive THEN
transform
draw
------------------------------
update(time)
move(dt)
compute next position
------------------------------
// used to know if the projectile should be removed from the list of projectiles
isDead(): bool
kill()
------------------------------
hit(obstacle)
kill itself
==============================