-
Notifications
You must be signed in to change notification settings - Fork 6
/
Demo3.lua
660 lines (598 loc) · 23.4 KB
/
Demo3.lua
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
-- demo script (for demo 2): Player is Ishiman Heavy Cruiser, opponent is Gaitori Carrier.
-- Carrier has no AI, so it just sits there. Player must warp to Carrier's position
-- and can destroy it using both seeking and non-seeking weapons. After that, the player must
-- capture the planet that the Gaitori Carrier was protecting by building an Ishiman Transport.
-- Script ends when the Carrier is destroyed and the planet is taken.
-- Future possible script variations:
-- Using autopilot to find Carrier.
-- Carrier has a "fleeing" AI, and runs away when attacked, possibly warping away.
-- Carrier has other AIs.
-- Use other Heavy Cruisers (possibly built on planets) to destroy Carrier, using attack command.
import('PrintRecursive')
import('GlobalVars')
import('EntityLoad')
import('Math')
import('Interfaces')
import('PopDownConsole')
import('CaptainAI')
import('BoxDrawing')
import('KeyboardControl')
-- import('MouseHandle')
import('Weapons')
position = nil
endGameData = nil
--[[--------------------------------
--{{------------------------
Projectile Collision
------------------------}}--
--------------------------------]]--
function ProjectileCollision(projectileObject, pNum, projectileData, shipObject)
table.remove(projectileObject, pNum)
shipObject.life = shipObject.life - projectileData.damage
end
--[[--------------------------
--{{------------------
Initialization
------------------}}--
--------------------------]]--
mouse_movement = false
mousePos = vec(0, 0)
mouseStart = 0
function init ()
start_time = mode_manager.time()
sound.stop_music()
lastTime = mode_manager.time()
physics.open(0.6)
loadingEntities = true
Admirals[1] = { ident = "Human/Ishiman", name = "Human / Ishiman Cooperative" }
Admirals[2] = { ident = "Gaitori", name = "Gaitori Union" }
if scen == nil then
scen = NewEntity(nil, "demo", "Scenario")
end
loadingEntities = false
computerShip = NewEntity(nil, "Carrier", "Ship", "Gaitori")
computerShip.physicsObject.position = { x = 2200, y = 2700 }
computerShip.physicsObject.angle = math.pi - 0.2
computerShip.owner = "Gaitori"
playerShip = NewEntity(nil, "HeavyCruiser", "Ship", "Ishiman")
playerShip.owner = "Human/Ishiman"
bestExplosion = NewEntity(nil, "BestExplosion", "Explosion")
end
--[[--------------------
--{{------------
Updating
------------}}--
--------------------]]--
function temp_key(k)
if k ~= nil then
mode_manager.switch('Xsera/Credits')
end
end
function update ()
local newTime = mode_manager.time()
dt = newTime - lastTime
lastTime = newTime
if printFPS == true then
print(1 / dt) -- fps counter! whoa... o.O
end
-- victory condition
if victoryTimer ~= nil then
victoryTimer = victoryTimer + dt
if victoryTimer >= 2.0 then
key = temp_key
end_time = mode_manager.time()
endGameData = { { { false, cClear, " " },
{ false, ClutColour(3, 7), "YOU" },
{ false, ClutColour(3, 9), "PAR" } },
{ { false, ClutColour(3, 7), "TIME" },
{ false, cClear, (tostring(math.floor((end_time - start_time) / 60)) .. ":" .. tostring(string.format('%02d', math.floor((end_time - start_time) % 60))))},
{ false, cClear, "1:00" } },
{ { false, ClutColour(3, 9), "LOSSES" },
{ false, cClear, "0" },
{ false, cClear, "0" } },
{ { false, ClutColour(3, 11), "KILLS" },
{ false, cClear, "1" },
{ false, cClear, "1" } },
{ { false, ClutColour(3, 13), "SCORE" },
{ false, cClear, ">9000!!!" },
{ false, cClear, "100" } } }
menu_display = "victory_menu"
victoryTimer = nil
end
end
-- defeat condition
if playerShip.life == 0 then
defeatTimer = defeatTimer + dt
victoryTimer = nil
if defeatTimer >= 2.0 then
menu_display = "defeat_menu"
keyup = escape_keyup
key = escape_key
end
end
--[[------------------
Camera Code
------------------]]--
--[[ plan for hostile zoom [ADAM]
set cameraChanging = "constant" if the ratio of the change that needs to be made is small enough (start it off at around 0.5 - or half as big - and test)
make an elseif under "if cameraChanging == true then": "elseif cameraChanging == "constant" then"
if cameraChanging == "constant", we want it to update differently than if cameraChanging == true - it needs to be a smooth transition (what makes it smooth?)
--]]
--[[ this structure needs to be removed
if cameraRatio.num > 5 and cameraChanging == false then
-- this is constantly modified, but not done smoothly, so it looks bad
if cameraRatio.num == 6 then
local diff = { x = math.abs(computerShip.physicsObject.position.x - playerShip.physicsObject.position.x) + computerShip.size.x / 2, y = math.abs(computerShip.physicsObject.position.y - playerShip.physicsObject.position.y) + computerShip.size.y / 2 }
cameraRatio.orig = cameraRatio.curr
if (math.abs(hypot1(diff) / hypot1(camera)) > 0.5) then
cameraChanging = true
x = 0.6
timeInterval = 0.6
cameraRatio.orig = cameraRatio.curr
else
if diff.x == 0 or diff.y == 0 or aspectRatio == 0 then
cameraRatio.curr = 2
else
cameraRatio.curr = (440) / (hypot1(diff) * 2)
end
end
else
print("DONT DO EET") -- temp error message because cameraRatio.num is greater than 5 but not equal to 6, somehow
end
if cameraRatio.curr > 2 then
cameraRatio.curr = 2
end
if (cameraRatio.curr < 1 / 8 and cameraRatio.orig > 1 / 8) or (cameraRatio.curr > 1 / 8 and cameraRatio.orig < 1 / 8) then
sound.play("ZoomChange")
end
camera = { w = 640 / cameraRatio.curr, h }
camera.h = camera.w / aspectRatio
shipAdjust = .045 * camera.w
arrowLength = ARROW_LENGTH / cameraRatio.curr
arrowVar = ARROW_VAR / cameraRatio.curr
arrowDist = ARROW_DIST / cameraRatio.curr
end--]]
if cameraChanging == true then
x = x - dt
if x < 0 then
x = 0
cameraChanging = false
playerShip.beam.width = cameraRatio.curr
soundJustPlayed = false
end
if x >= 0 then
cameraRatio.curr = cameraRatio.orig + cameraRatio.orig * multiplier * math.pow(math.abs((x - timeInterval) / timeInterval), 2) --[[* (((x - timeInterval) * (x - timeInterval) * math.sqrt(math.abs(x - timeInterval))) / (timeInterval * timeInterval * math.sqrt(math.abs(timeInterval))))--]]
-- print(cameraRatio.curr, timeInterval)
end
camera = { w = 640 / cameraRatio.curr, h }
camera.h = camera.w / aspectRatio
shipAdjust = .045 * camera.w
arrowLength = ARROW_LENGTH / cameraRatio.curr
arrowVar = ARROW_VAR / cameraRatio.curr
arrowDist = ARROW_DIST / cameraRatio.curr
if (cameraRatio.curr < 1 / 8 and cameraRatio.orig > 1 / 8) or (cameraRatio.curr > 1 / 8 and cameraRatio.orig < 1 / 8) then
if soundJustPlayed == false then
sound.play("ZoomChange")
soundJustPlayed = true
end
end
end
--[[------------------
Warping Code
------------------]]-- it's a pair of lightsabers!
if playerShip.warp.stage ~= "notWarping" then
if playerShip.warp.stage == "warping" then
playerShip.physicsObject.velocity = { x = playerShip.warpSpeed * math.cos(playerShip.physicsObject.angle), y = playerShip.warpSpeed * math.sin(playerShip.physicsObject.angle) }
elseif playerShip.warp.stage == "cooldown" then
slowDownTime = 2 -- [HARDCODE]
if (playerShip.warp.time < slowDownTime) then
playerShip.physicsObject.velocity = { x = (playerShip.maxSpeed + (playerShip.warpSpeed - playerShip.maxSpeed) * (slowDownTime - playerShip.warp.time) / slowDownTime) * math.cos(playerShip.physicsObject.angle), y = (playerShip.maxSpeed + (playerShip.warpSpeed - playerShip.maxSpeed) * (slowDownTime - playerShip.warp.time) / slowDownTime) * math.sin(playerShip.physicsObject.angle) }
else
sound.play("WarpOut")
playerShip.physicsObject.velocity = { x = playerShip.maxSpeed * normalize(playerShip.physicsObject.velocity.x, playerShip.physicsObject.velocity.y), y = playerShip.maxSpeed * normalize(playerShip.physicsObject.velocity.y, playerShip.physicsObject.velocity.x) }
playerShip.warp.stage = "notWarping"
scen.playerShip.control.warp = false
end
end
elseif hypot (playerShip.physicsObject.velocity.x, playerShip.physicsObject.velocity.y) > playerShip.maxSpeed then
playerShip.physicsObject.velocity = { x = playerShip.maxSpeed * normalize(playerShip.physicsObject.velocity.x, playerShip.physicsObject.velocity.y), y = playerShip.maxSpeed * normalize(playerShip.physicsObject.velocity.y, playerShip.physicsObject.velocity.x) }
end
--[[------------------
Movement
------------------]]--
if keyboard[1][4].active == true then
if key_press_f6 ~= true then
playerShip.physicsObject.angularVelocity = playerShip.turningRate
else
playerShip.physicsObject.angularVelocity = playerShip.turningRate / 10
end
elseif keyboard[1][5].active == true then
if key_press_f6 ~= true then
playerShip.physicsObject.angularVelocity = -playerShip.turningRate
else
playerShip.physicsObject.angularVelocity = -playerShip.turningRate / 10
end
else
playerShip.physicsObject.angularVelocity = 0
end
if keyboard[1][2].active == true and playerShip.warp.stage == "notWarping" then
-- apply a forward force in the direction the ship is facing
local angle = playerShip.physicsObject.angle
local thrust = playerShip.thrust
local force = { x = thrust * math.cos(angle), y = thrust * math.sin(angle) }
playerShip.physicsObject:apply_force(force)
elseif keyboard[1][3].active == true and playerShip.warp.stage == "notWarping" then
-- apply a reverse force in the direction opposite the direction the ship is MOVING
local force = playerShip.physicsObject.velocity
if force.x ~= 0 or force.y ~= 0 then
if hypot(playerShip.physicsObject.velocity.x, playerShip.physicsObject.velocity.y) <= 10 then
playerShip.physicsObject.velocity = vec(0, 0)
else
local velocityMag = hypot(force.x, force.y)
force.x = -force.x / velocityMag
force.y = -force.y / velocityMag
force.x = force.x * playerShip.reverseThrust
force.y = force.y * playerShip.reverseThrust
if hypot1(force) > hypot1(playerShip.physicsObject.velocity) then
playerShip.physicsObject.velocity = vec(0, 0)
else
playerShip.physicsObject:apply_force(force)
end
end
end
end
if showVelocity == true then
print(playerShip.physicsObject.velocity.x)
print(playerShip.physicsObject.velocity.y)
end
--[[------------------
C-Missile Firing
------------------]]--
if playerShip.special ~= nil then
WeaponManage(playerShip.special, playerShip.specialWeap, playerShip)
--seeking code
local wNum = 1
while wNum <= playerShip.special.max_projectiles do
if playerShip.specialWeap[wNum] ~= nil then
if playerShip.specialWeap[wNum].isSeeking == true then
playerShip.specialWeap[wNum].theta = find_angle(playerShip.specialWeap[wNum].physicsObject.position, playerShip.special.dest)
if playerShip.specialWeap[wNum].physicsObject.angle ~= playerShip.specialWeap[wNum].theta then
playerShip.specialWeap[wNum].delta = playerShip.specialWeap[wNum].theta - playerShip.specialWeap[wNum].physicsObject.angle
if math.abs(playerShip.specialWeap[wNum].delta) > math.pi then -- need to go through 0
if playerShip.specialWeap[wNum].delta > 0.0 then
playerShip.specialWeap[wNum].delta = 2 * math.pi - playerShip.specialWeap[wNum].delta
else
playerShip.specialWeap[wNum].delta = 2 * math.pi + playerShip.specialWeap[wNum].delta
end
end
if math.abs(playerShip.specialWeap[wNum].delta) > playerShip.specialWeap[wNum].turningRate * dt then
if playerShip.specialWeap[wNum].delta > playerShip.specialWeap[wNum].turningRate * dt then
playerShip.specialWeap[wNum].delta = -playerShip.specialWeap[wNum].turningRate * dt
else
playerShip.specialWeap[wNum].delta = playerShip.specialWeap[wNum].turningRate * dt
end
end
else
playerShip.specialWeap[wNum].delta = 0.0
end
else
playerShip.specialWeap[wNum].delta = 0.0
end
playerShip.specialWeap[wNum].physicsObject.angle = playerShip.specialWeap[wNum].physicsObject.angle + playerShip.specialWeap[wNum].delta
playerShip.specialWeap[wNum].force = { x = math.cos(playerShip.specialWeap[wNum].physicsObject.angle) * playerShip.special.thrust / playerShip.special.mass, y = math.sin(playerShip.specialWeap[wNum].physicsObject.angle) * playerShip.special.thrust / playerShip.special.mass }
playerShip.specialWeap[wNum].physicsObject:apply_force(playerShip.specialWeap[wNum].force)
if showAngles == true then
print("For special #" .. wNum .. ":")
print(playerShip.specialWeap[wNum].physicsObject.angle)
print(playerShip.specialWeap[wNum].theta)
print(playerShip.specialWeap[wNum].delta)
print("----------------")
end
wNum = playerShip.special.max_projectiles
end
wNum = wNum + 1
end
--/seeking code
end
-- PKBeam Firing
WeaponManage(playerShip.beam, playerShip.beamWeap, playerShip)
-- Pathfinding for Ishiman Transports
local num = 1
if otherShip ~= nil then
while otherShip[num] ~= nil do
if otherShip[num].name == "Transport" then
ai_pathfind(dt, otherShip[num], scen.planet2.position, computerShip)
if otherShip[num].landing_size == 0 then
table.remove(otherShip, num)
end
end
num = num + 1
end
end
--[[------------------
Panels
------------------]]--
resourceTime = resourceTime + dt
if resourceTime > 1 then
resourceTime = resourceTime - 1
cash = cash + 20
resourceBars = math.floor(cash / 20000)
resources = math.floor((cash % 20000) / 200)
end
if buildTimerRunning == true then
scen.planet.buildqueue.current = scen.planet.buildqueue.current + dt
scen.planet.buildqueue.percent = scen.planet.buildqueue.current / scen.planet.buildqueue.factor * 100
if planet.buildqueue.percent > 100.0 then
local num = 1
if otherShip == nil then
otherShip = {}
end
while otherShip[num] ~= nil do
num = num + 1
end
if num == 3 and otherShip[2] == nil then -- I don't know why this works, but it does
num = num - 1
end
otherShip[num] = NewEntity(shipBuilding.p, shipBuilding.n, "Ship", shipBuilding.r)
-- print(otherShip[num], playerShip)
planet.buildqueue.percent = 100
buildTimerRunning = false
sound.play("ComboBeep")
end
end
playerShip.battery.percent = playerShip.battery.current / playerShip.battery.total
playerShip.energy.percent = playerShip.energy / playerShip.energy.total
playerShip.shield.percent = playerShip.shield.current / playerShip.shield.total
if playerShip.energy.percent ~= 1.0 then
rechargeTimer = rechargeTimer + dt
if rechargeTimer >= 0.5 then
if playerShip.battery.percent ~= 0.0 then
playerShip.battery.current = playerShip.battery.current - 1
playerShip.energy = playerShip.energy + 1
rechargeTimer = rechargeTimer - 0.5
end
end
end
if menu_display == nil then
if keyboard[4][7].active == false then
physics.update(dt)
else
physics.update(dt * 30)
end
end
KeyDoActivated()
end
--[[---------------------
--{{-------------
Rendering
-------------}}--
---------------------]]--
function render ()
graphics.begin_frame()
local warpStatus = 0.0
if playerShip.warp.stage == "warping" then
warpStatus = 1.0
elseif playerShip.warp.stage == "spooling" then
warpStatus = playerShip.warp.time / 0.8
if warpStatus > 1.0 then
warpStatus = 1.0
end
else
warpStatus = 0.0
end
graphics.begin_warp(warpStatus, (2.5*math.pi) - math.atan2(playerShip.physicsObject.velocity.x, playerShip.physicsObject.velocity.y), cameraRatio.curr)
-- extract camera coordinates from here during update() and place finalized numbers here
graphics.set_camera(-playerShip.physicsObject.position.x + shipAdjust - (camera.w / 2.0), -playerShip.physicsObject.position.y - (camera.h / 2.0), -playerShip.physicsObject.position.x + shipAdjust + (camera.w / 2.0), -playerShip.physicsObject.position.y + (camera.h / 2.0))
graphics.draw_starfield(3.4)
graphics.draw_starfield(1.8)
graphics.draw_starfield(0.6)
graphics.draw_starfield(-0.3)
graphics.draw_starfield(-0.9)
--[[------------------
Grid Drawing
------------------]]--
local i = 0
while i ~= 500 do
if (i * GRID_DIST_BLUE) % GRID_DIST_LIGHT_BLUE == 0 then
if (i * GRID_DIST_BLUE) % GRID_DIST_GREEN == 0 then
graphics.draw_line({ x = -60000, y = -i * GRID_DIST_BLUE }, { x = 60000, y = -i * GRID_DIST_BLUE }, 1, ClutColour(5, 1))
graphics.draw_line({ x = -60000, y = i * GRID_DIST_BLUE }, { x = 60000, y = i * GRID_DIST_BLUE }, 1, ClutColour(5, 1))
graphics.draw_line({ x = -i * GRID_DIST_BLUE, y = -60000 }, { x = -i * GRID_DIST_BLUE, y = 60000 }, 1, ClutColour(5, 1))
graphics.draw_line({ x = i * GRID_DIST_BLUE, y = -60000 }, { x = i * GRID_DIST_BLUE, y = 60000 }, 1, ClutColour(5, 1))
else
graphics.draw_line({ x = -60000, y = -i * GRID_DIST_BLUE }, { x = 60000, y = -i * GRID_DIST_BLUE }, 1, ClutColour(4, 8))
graphics.draw_line({ x = -60000, y = i * GRID_DIST_BLUE }, { x = 60000, y = i * GRID_DIST_BLUE }, 1, ClutColour(4, 8))
graphics.draw_line({ x = -i * GRID_DIST_BLUE, y = -60000 }, { x = -i * GRID_DIST_BLUE, y = 60000 }, 1, ClutColour(4, 8))
graphics.draw_line({ x = i * GRID_DIST_BLUE, y = -60000 }, { x = i * GRID_DIST_BLUE, y = 60000 }, 1, ClutColour(4, 8))
end
else
if cameraRatio.curr > 1 / 8 then
graphics.draw_line({ x = -60000, y = -i * GRID_DIST_BLUE }, { x = 60000, y = -i * GRID_DIST_BLUE }, 1, ClutColour(4, 11))
graphics.draw_line({ x = -60000, y = i * GRID_DIST_BLUE }, { x = 60000, y = i * GRID_DIST_BLUE }, 1, ClutColour(4, 11))
graphics.draw_line({ x = -i * GRID_DIST_BLUE, y = -60000 }, { x = -i * GRID_DIST_BLUE, y = 60000 }, 1, ClutColour(4, 11))
graphics.draw_line({ x = i * GRID_DIST_BLUE, y = -60000 }, { x = i * GRID_DIST_BLUE, y = 60000 }, 1, ClutColour(4, 11))
end
end
i = i + 1
end
--[[------------------
Planet Drawing
------------------]]--
function drawPlanet(planet)
if cameraRatio.curr > 1 / 8 then
local planetCoord = graphics.sprite_dimensions("Planets/" .. planet.image)
graphics.draw_sprite("Planets/" .. planet.image, planet.position, planetCoord, 1)
else
if planet.owner ~= Admirals[1].ident then
graphics.draw_rbox(planet.position, 60, ClutColour(16, 1))
else
graphics.draw_rbox(planet.position, 60)
end
end
end
drawPlanet(scen.planet)
drawPlanet(scen.planet2)
--[[------------------
Ship Drawing
------------------]]--
if computerShip ~= nil then
if computerShip.life > 0 then
if cameraRatio.curr > 1 / 8 then
graphics.draw_sprite("Ships/Gaitori/Carrier", computerShip.physicsObject.position, computerShip.size, computerShip.physicsObject.angle)
else
graphics.draw_rdia(computerShip.physicsObject.position, 60, ClutColour(16, 1) )
end
else
-- This explosion code is a hack. We need a way to deal with explosions in a better method.
-- Let's figure it out when we get Sfiera's data
if computerShip ~= nil then
if cameraRatio.curr > 1 / 8 then
graphics.draw_sprite(bestExplosion.image, computerShip.physicsObject.position, bestExplosion.size, frame / 6 * math.pi)
end
if frame == 0 then
sound.play("New/ExplosionCombo")
end
if frame >= 12 then
computerShip = nil
else
frame = frame + dt * 50
end
end
end
end
if otherShip ~= nil then
num = 1
while otherShip[num] ~= nil do
if cameraRatio.curr > 1 / 8 then
if otherShip[num].name ~= "Transport" then
graphics.draw_sprite(otherShip[num].image, otherShip[num].physicsObject.position, otherShip[num].size, otherShip[num].physicsObject.angle)
else
graphics.draw_sprite(otherShip[num].image, otherShip[num].physicsObject.position, { x = otherShip[num].size.x * otherShip[num].landing_size, y = otherShip[num].size.y * otherShip[num].landing_size }, otherShip[num].physicsObject.angle)
end
else
if otherShip[num].name ~= "Transport" then
graphics.draw_rtri(otherShip[num].physicsObject.position, 60)
else
graphics.draw_rplus(otherShip[num].physicsObject.position, 60)
end
end
num = num + 1
end
end
--[[------------------
PKBeam Firing
------------------]]--
-- printTable(playerShip.beamWeap)
if playerShip.beam.fired == true then
local wNum = 1
while wNum <= playerShip.beam.max_projectiles do
if playerShip.beamWeap[wNum] ~= nil then
graphics.draw_line(playerShip.beamWeap[wNum].physicsObject.position, { x = playerShip.beamWeap[wNum].physicsObject.position.x - math.cos(playerShip.beamWeap[wNum].physicsObject.angle) * playerShip.beam.length, y = playerShip.beamWeap[wNum].physicsObject.position.y - math.sin(playerShip.beamWeap[wNum].physicsObject.angle) * playerShip.beam.length }, playerShip.beam.width, ClutColour(5, 1))
end
wNum = wNum + 1
end
end
--[[------------------
C-Missile Firing
------------------]]--
if playerShip.special.fired == true then
local wNum = 1
while wNum <= playerShip.special.max_projectiles do
if playerShip.specialWeap[wNum] ~= nil then
printTable(playerShip.special)
graphics.draw_sprite("Weapons/Special/cMissile", playerShip.specialWeap[wNum].physicsObject.position, playerShip.special.size, playerShip.specialWeap[wNum].physicsObject.angle)
end
wNum = wNum + 1
end
end
graphics.end_warp()
if cameraRatio.curr > 1 / 8 then
graphics.draw_sprite(playerShip.image, playerShip.physicsObject.position, playerShip.size, playerShip.physicsObject.angle)
else
graphics.draw_rtri(playerShip.physicsObject.position, 60)
end
--[[------------------
Miscellaneous
------------------]]--
-- Arrow
DrawArrow()
-- Panels
DrawPanels()
-- Console
PopDownConsole()
-- Mouse
--[[ disabled for now
--if mouseMovement == true then
-- draw mouse replacement
-- check to see if it's over the panels
-- if it's not, draw the lines coming inward
mousePos.x, mousePos.y = input.mouse_position()
graphics.draw_line({ x = -410, y = mousePos.y }, { x = mousePos.x - 20, y = mousePos.y }, 1.0, ClutColour(4, 8))
graphics.draw_line({ x = 410, y = mousePos.y }, { x = mousePos.x + 20, y = mousePos.y }, 1.0, ClutColour(4, 8))
graphics.draw_line({ x = mousePos.x, y = -310 }, { x = mousePos.x, y = mousePos.y - 20 }, 1.0, ClutColour(4, 8))
graphics.draw_line({ x = mousePos.x, y = 310 }, { x = mousePos.x, y = mousePos.y + 20 }, 1.0, ClutColour(4, 8))
-- if it is, draw the cursor
local cursor = graphics.sprite_dimensions("Misc/Cursor")
graphics.draw_sprite("Misc/Cursor", mousePos, cursor, 0)
-- check mouse idleness timer
--if mode_manager.time() - mouseStart >= 2.0 then
-- mouseMovement = false
--end
--end
--]]
-- Menus
InterfaceDisplay(dt)
-- Error Printing
if errNotice ~= nil then
graphics.draw_text(errNotice.text, MAIN_FONT, "center", { x = 0, y = -150 }, 28)
if errNotice.start + errNotice.duration < mode_manager.time() then
errNotice = nil
end
end
graphics.end_frame()
end
--[[------------------------
--{{----------------
Key Handling
----------------}}--
------------------------]]--
function keyup ( k )
KeyDeactivate(k)
end
normal_keyup = keyup
function key ( k )
if k == "`" then
if RELEASE_BUILD == false then
consoleDraw = true
end
elseif k == "p" then
if RELEASE_BUILD == false then
computerShip.life = 0
end
elseif k == "o" then
if RELEASE_BUILD == false then
menu_display = "pause_menu"
end
elseif k == "[" then
if RELEASE_BUILD == false then
playerShip.life = 0
keyup = escape_keyup
key = escape_key
end
elseif k == "escape" then
menu_display = "esc_menu"
keyup = escape_keyup
key = escape_key
else
KeyActivate(k)
end
end
normal_key = key
function mouse(button, mbX, mbY)
-- print(mbX, mbY)
end
function mouse_up(button, mbX, mbY)
end
function quit ()
physics.close()
end