summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-05-27 13:11:11 +0200
committerAki <nthirtyone@gmail.com>2016-05-27 13:11:11 +0200
commit8adcd1d14ee076d7a2db6303d0b5b938977d356b (patch)
treea24b6063d3dab3584cfddab1c984e1418b31cd7d
parent6672ea6ee588452fbbbd6996af160e4059643d16 (diff)
downloadroflnauts-8adcd1d14ee076d7a2db6303d0b5b938977d356b.zip
roflnauts-8adcd1d14ee076d7a2db6303d0b5b938977d356b.tar.gz
roflnauts-8adcd1d14ee076d7a2db6303d0b5b938977d356b.tar.bz2
More controllers updates
-rw-r--r--controller.lua3
-rw-r--r--main.lua37
-rw-r--r--world.lua14
3 files changed, 22 insertions, 32 deletions
diff --git a/controller.lua b/controller.lua
index 9e1d8c9..d00f434 100644
--- a/controller.lua
+++ b/controller.lua
@@ -10,8 +10,7 @@ Controller = {
down = "down",
attack = "return", -- accept
jump = "rshift", -- cancel
- parent = nil,
- down = nil
+ parent = nil
}
-- Constructor
diff --git a/main.lua b/main.lua
index b5c8840..05a21f4 100644
--- a/main.lua
+++ b/main.lua
@@ -3,7 +3,7 @@
require "world"
require "camera"
---require "menu"
+-- require "menu"
require "controller"
-- Temporary debug
@@ -26,14 +26,17 @@ function love.load ()
w = World:new("default", "leon", "lonestar", third, fourth)
-- Controllers
- cont1 = Controller:new()
- cont2 = Controller:new(nil, "a", "d", "w", "s", "g", "h")
- w.Nauts[1]:assignController(cont1)
- w.Nauts[2]:assignController(cont2)
+ Controllers = {}
+ table.insert(Controllers, Controller:new())
+ table.insert(Controllers, Controller:new(nil, "a", "d", "w", "s", "g", "h"))
+ w.Nauts[1]:assignController(Controllers[1])
+ w.Nauts[2]:assignController(Controllers[2])
-- Menu bijaczes
- --m = Menu:new()
- --m:newSelector()
+ -- m = Menu:new()
+ -- m:newSelector()
+ -- m:newSelector()
+ -- m.selectors[2]:setPosition(33,33)
end
-- Update
@@ -43,14 +46,15 @@ end
-- KeyPressed
function love.keypressed (key)
- w:keypressed(key)
- cont1:keypressed(key)
- cont2:keypressed(key)
- -- Switch hitbox display on/off
+ -- Controllers
+ for _,controller in pairs(Controllers) do
+ controller:keypressed(key)
+ end
+ -- Misc global input
if key == "x" then
debug = not debug
end
- if key == "escape" then
+ if key == "escape" or key == "f1" then
love.event.quit()
end
if key == "f5" and debug then
@@ -64,15 +68,16 @@ end
-- KeyReleased
function love.keyreleased(key)
- w:keyreleased(key)
- cont1:keyreleased(key)
- cont2:keyreleased(key)
+ -- Controllers
+ for _,controller in pairs(Controllers) do
+ controller:keyreleased(key)
+ end
end
-- Draw
function love.draw ()
w:draw()
- --m.selectors[1]:draw()
+ -- m:draw()
if debug then
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
end
diff --git a/world.lua b/world.lua
index 6762bc6..0b70bcb 100644
--- a/world.lua
+++ b/world.lua
@@ -162,20 +162,6 @@ function World:update(dt)
end
end
--- Keypressed
-function World:keypressed(key)
- for _,naut in pairs(self.Nauts) do
- --naut:keypressed(key)
- end
-end
-
--- Keyreleased
-function World:keyreleased(key)
- for _,naut in pairs(self.Nauts) do
- --naut:keyreleased(key)
- end
-end
-
-- Draw
function World:draw()
-- Hard-coded background (for now)