summaryrefslogtreecommitdiffhomepage
path: root/main.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-08-13 02:26:55 +0200
committerAki <nthirtyone@gmail.com>2017-08-13 02:26:55 +0200
commitb1cf14d64a2d3e28683db87190c4b2c7799c259d (patch)
treee45dac5cc6ce5265e3e3e2c914eb7cc92a820b8b /main.lua
parent0dd01913fe0eefc7ba4bc0797877f40fdedf9315 (diff)
parented62b573417bdc85bec616f6016846b02de4c906 (diff)
downloadroflnauts-b1cf14d64a2d3e28683db87190c4b2c7799c259d.zip
roflnauts-b1cf14d64a2d3e28683db87190c4b2c7799c259d.tar.gz
roflnauts-b1cf14d64a2d3e28683db87190c4b2c7799c259d.tar.bz2
Merge branch 'multi'maps
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua30
1 files changed, 10 insertions, 20 deletions
diff --git a/main.lua b/main.lua
index 11e4d95..ac04383 100644
--- a/main.lua
+++ b/main.lua
@@ -1,17 +1,6 @@
--- Roflnauts 2
-- TODO: Any lua source file in root directory that is not `main` (this file), `conf` should be moved to a proper directory. Its name should be changed to show what it contains.
--- Pretend you didn't see this
--- This is work for scene manager
--- TODO: Create SceneManager or similar class.
-Scene = nil
-function changeScene (scene)
- if Scene ~= nil then
- Scene:delete()
- end
- Scene = scene
-end
-
-- Should be moved to scene/camera
-- TODO: move following functions to `Camera`.
function getScale ()
@@ -22,6 +11,10 @@ function getRealScale ()
return math.max(1, math.max(love.graphics.getWidth() / 320, love.graphics.getHeight() / 180))
end
+-- TODO: They don't look nice like this; move them to some kind of core/game object.
+musicPlayer = require "not.MusicPlayer"()
+sceneManager = require "not.SceneManager"()
+
-- Require
require "iconsList"
require "not.World"
@@ -44,11 +37,11 @@ function love.load ()
love.graphics.setFont(Font)
Controller.load()
Settings.load()
- Scene = Menu:new()
+ sceneManager:changeScene(Menu())
end
function love.draw ()
- Scene:draw()
+ sceneManager:draw()
if debug then
local scale = getScale()
love.graphics.setFont(Font)
@@ -59,7 +52,7 @@ function love.draw ()
end
end
-function love.update (dt) Scene:update(dt) end
+function love.update (dt) sceneManager:update(dt) end
function love.quit () Settings.save() end
-- Pass input to Controller
@@ -71,15 +64,12 @@ function love.keyreleased (key) Controller.keyreleased(key) end
-- Controller callbacks
function Controller.controlpressed (set, action, key)
- Scene:controlpressed(set, action, key)
- if key == "escape" then
- love.event.quit()
- end
+ sceneManager:controlpressed(set, action, key)
if key == "f5" then
debug = not debug
end
end
function Controller.controlreleased (set, action, key)
- Scene:controlreleased(set, action, key)
-end \ No newline at end of file
+ sceneManager:controlreleased(set, action, key)
+end