summaryrefslogtreecommitdiffhomepage
path: root/menu.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-14 23:08:38 +0200
committerAki <nthirtyone@gmail.com>2016-08-14 23:08:38 +0200
commit22c36dfaac394ef8148d50a95c862e937b4e908a (patch)
treebb51799daa48252846c6786afd4bdbd77a71cd03 /menu.lua
parent7d4f54ff43c19d590f7dc3fb2803442b4b469ee6 (diff)
downloadroflnauts-22c36dfaac394ef8148d50a95c862e937b4e908a.zip
roflnauts-22c36dfaac394ef8148d50a95c862e937b4e908a.tar.gz
roflnauts-22c36dfaac394ef8148d50a95c862e937b4e908a.tar.bz2
Moved love callbacks for readability
Diffstat (limited to 'menu.lua')
-rw-r--r--menu.lua76
1 files changed, 38 insertions, 38 deletions
diff --git a/menu.lua b/menu.lua
index 5b84f83..cfce246 100644
--- a/menu.lua
+++ b/menu.lua
@@ -107,6 +107,44 @@ function Menu:getBounce(f)
return math.sin(self.header_move*f*math.pi)
end
+-- Speed up countdown
+function Menu:countdownJump()
+ if self.countdown ~= Menu.countdown then -- Menu.countdown is initial
+ self.countdown = self.countdown - 1
+ end
+end
+
+-- Called when selector is deactivated
+function Menu:unselectSelector(selector)
+ local i = 0
+ for _,v in pairs(self:getSelectorsActive()) do
+ if v == selector then
+ i = _
+ break
+ end
+ end
+ if i ~= 0 then
+ self:assignController(selector:getController())
+ selector:clear()
+ end
+end
+
+-- Get table of nauts currently selected by active selectors
+function Menu:getNauts()
+ local nauts = {}
+ for _,selector in pairs(self:getSelectorsActive()) do
+ table.insert(nauts, {selector:getSelectionName(), selector:getController()})
+ end
+ return nauts
+end
+
+-- WARUDO
+function Menu:startGame()
+ local world = World:new(self.maplist[self.map], self:getNauts())
+ changeScene(world)
+end
+
+-- LÖVE2D callbacks
-- Update
function Menu:update(dt)
local state = true
@@ -131,7 +169,6 @@ function Menu:update(dt)
self.header_move = self.header_move - 2
end
end
-
-- Draw
function Menu:draw()
-- locals
@@ -160,43 +197,6 @@ function Menu:draw()
end
end
--- Speed up countdown
-function Menu:countdownJump()
- if self.countdown ~= Menu.countdown then -- Menu.countdown is initial
- self.countdown = self.countdown - 1
- end
-end
-
--- Called when selector is deactivated
-function Menu:unselectSelector(selector)
- local i = 0
- for _,v in pairs(self:getSelectorsActive()) do
- if v == selector then
- i = _
- break
- end
- end
- if i ~= 0 then
- self:assignController(selector:getController())
- selector:clear()
- end
-end
-
--- Get table of nauts currently selected by active selectors
-function Menu:getNauts()
- local nauts = {}
- for _,selector in pairs(self:getSelectorsActive()) do
- table.insert(nauts, {selector:getSelectionName(), selector:getController()})
- end
- return nauts
-end
-
--- WARUDO
-function Menu:startGame()
- local world = World:new(self.maplist[self.map], self:getNauts())
- changeScene(world)
-end
-
-- Controller callbacks
function Menu:controlpressed(set, action, key)
-- assign to character selection