aboutsummaryrefslogtreecommitdiff
path: root/src/game.moon
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2020-02-02 08:11:08 -0500
committerAlexander Pickering <alex@cogarr.net>2020-02-02 08:11:08 -0500
commit57701059b1b65fc08366318e92d32d9dd7094d25 (patch)
treea569db68d27982d83fead3cc9c8192056c49509f /src/game.moon
downloaddrydock-57701059b1b65fc08366318e92d32d9dd7094d25.tar.gz
drydock-57701059b1b65fc08366318e92d32d9dd7094d25.tar.bz2
drydock-57701059b1b65fc08366318e92d32d9dd7094d25.zip
inital commit
Diffstat (limited to 'src/game.moon')
-rw-r--r--src/game.moon131
1 files changed, 131 insertions, 0 deletions
diff --git a/src/game.moon b/src/game.moon
new file mode 100644
index 0000000..037511a
--- /dev/null
+++ b/src/game.moon
@@ -0,0 +1,131 @@
+state = require "global"
+level1 = require "level1"
+level2 = require "level2"
+level3 = require "level3"
+level3p2 = require"level3p2"
+level4 = require "level4"
+level5 = require "level5"
+level6 = require "level6"
+level7 = require "level7"
+level8 = require "level8"
+level9 = require "level9"
+level10 = require "level10"
+level11 = require "level11"
+level12 = require "level12"
+game_complete = require "complete"
+ui = require "ui"
+mod = ...
+
+mod.ship_move_in_co = () ->
+ while true
+ while ui.manager_talking
+ coroutine.yield!
+ state.ship("sprite").color = vec4(1,1,1,1)
+ state.game_grid.hidden = true
+ state.layers.hidden = true
+ dist = state.ship("position").x - (state.win.left + 256) - 3
+ if dist > 3
+ state.ship("position").x = state.ship("position").x - (20*math.sin(dist / 512))
+ else
+ state.ship("sprite").color = vec4(0.5, 0.5, 0.5, 1)
+ state.game_grid.hidden = false
+ state.layers.hidden = false
+ break
+ coroutine.yield!
+ coroutine.yield true
+
+mod.ship_move_out_co = () ->
+ start_pos = state.ship("position").x
+ state.layers.hidden=true
+ state.game_grid.hidden =true
+ while true
+ print("Doing ship move out co...")
+ state.ship("sprite").color = vec4(1,1,1,1)
+ dist = state.ship("position").x - (state.win.left - 600 - 3)
+ if dist > 3
+ state.ship("position").x = state.ship("position").x - (20*math.sin(-start_pos / 512))
+ else
+ break
+ coroutine.yield!
+ state.move_out_done = true
+ coroutine.yield true
+
+mod.hint_mouse = () ->
+ mousepos = state.win\mouse_position!
+ mod.mouse_hint("position").x = mousepos.x
+ mod.mouse_hint("position").y = mousepos.y
+
+mod.gen_scene = () ->
+ state.selected_state = "electrical"
+ state.game_background = am.translate(0,0) ^ am.rotate(0) ^ am.scale(2) ^ am.sprite("data/space.jpg")
+ state.game_grid = am.translate(0,0) ^ am.scale(2) ^ am.rotate(0) ^ am.sprite("data/numbered_grid.png")\tag("sprite")
+ --state.game_grid = am.translate(0,0) ^ am.scale(2) ^ am.rotate(0) ^ am.sprite("data/grid.png")\tag("sprite")
+ state.game_grid("sprite").color = vec4(1,1,1,0.2)
+ state.ship = am.translate(1024,0)\tag("position") ^ am.scale(1) ^ am.rotate(math.pi / 2) ^ (am.sprite("data/test_ship.png")\tag("sprite"))
+ state.money = 100
+ gui = ui.make_ui!
+ ret = am.group! ^ {state.game_background, state.ship, state.game_grid, state.layers, gui}
+ state.layers.hidden = true
+ state.game_grid.hidden = true
+ state.mouse_hint = am.translate(0,0)\tag("position") ^ am.scale(1) ^ am.text("hint hint")\tag("sprite")
+ state.mouse_hint\action(coroutine.create(() ->
+ while true
+ state.mouse_hint("position").y -= 1
+ state.mouse_hint("sprite").color.a -= 0.01
+ coroutine.yield!
+ ))
+ state.ship\action(coroutine.create(() ->
+ ui.manager_say("Welcome to the drydocks, newbie. We're here to fix\nships as cheaply as possible. I'll start you off\nhooking up broken fuel lines.")
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ level1.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ ui.manager_say("If there are multiple tanks, you only need to\nconnect thrusters to one of them.")
+ level2.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ level3.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ level3p2.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ ui.manager_say("I think you're ready for the big time, use [1]\nand [2] to toggle between the fuel and electrical\ngrid. Ion thrusters need power to operate.")
+ level4.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ ui.manager_say("The credits from salvageing components from one grid\ncan be used in the other grid.")
+ level5.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ level6.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ level7.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ level8.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ ui.manager_say("Some ships use generators instead of batteries.\nConnect the generator to the fuel and the ion\nthrusters.")
+ level9.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ level10.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ ui.manager_say("Some ships have laser weapons, they need High\nvoltage power, which can't be next to regular\nvoltage or it'll interfere.")
+ level11.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ ui.manager_say("Ah, we're at the last ship already. You must have\nbeen quite clever to make it this far.")
+ level12.setup_level!
+ while not state.move_out_done or ui.manager_talking
+ coroutine.yield!
+ state.win.scene = game_complete.create_scene!
+
+ ))
+ --state.ship\action(coroutine.create(ship_move_in_co))
+ ret
+