aboutsummaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/main.lua b/main.lua
new file mode 100644
index 0000000..36294c2
--- /dev/null
+++ b/main.lua
@@ -0,0 +1,49 @@
+require "src.init"
+
+local lg = love.graphics
+
+function love.load()
+ main_init()
+ local scn = new_scene()
+ event_bind(scn.on_update, "Body", body_sys)
+ event_bind(scn.on_update, "Player", player_movement_sys)
+
+ event_bind(scn.on_draw, "Body", draw_sys)
+ set_scene(scn)
+
+ new_player(100, 100)
+end
+
+function love.update(dt)
+ local scn = get_current_scene()
+ assert(scn, "No scene set.")
+
+ fire_event(scn.on_update, dt)
+ flush_scene()
+end
+
+function love.draw(dt)
+ lg.origin()
+ lg.setCanvas(Viewport)
+ lg.clear()
+
+ local scn = get_current_scene()
+ assert(scn, "No scene set.")
+
+ fire_event(scn.on_draw, dt)
+
+ -- TODO: Take care of weird displays
+ lg.setCanvas()
+ local scr_width, scr_height = lg.getDimensions()
+ WindowScale = min(scr_width/SCR_WIDTH, scr_height/SCR_HEIGHT)
+
+ lg.draw(
+ Viewport,
+ scr_width/2, scr_height/2, 0,
+ WindowScale, WindowScale,
+ SCR_WIDTH/2, SCR_HEIGHT/2)
+
+ lg.print(tostring(love.timer.getFPS()))
+ input_step()
+end
+