summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--main.lua47
-rw-r--r--menu.lua13
-rw-r--r--selector.lua3
-rw-r--r--world.lua15
4 files changed, 47 insertions, 31 deletions
diff --git a/main.lua b/main.lua
index 575b7c8..1163516 100644
--- a/main.lua
+++ b/main.lua
@@ -8,8 +8,6 @@ require "controller"
-- Temporary debug
debug = false
-third = nil --"clunk"
-fourth = nil --"yuri"
-- Load
function love.load ()
@@ -22,36 +20,28 @@ function love.load ()
Font:setLineHeight(1)
love.graphics.setFont(Font)
- -- ZU WARUDO!
- w = World:new("default", "leon", "lonestar", third, fourth)
-
-- Menu bijaczes
- -- m = Menu:new()
- -- m:newSelector()
- -- m:newSelector()
- -- m:newSelector()
- -- m:newSelector()
- -- m.selectors[1]:setPosition(40+33*1,33)
- -- m.selectors[2]:setPosition(40+33*2,33)
- -- m.selectors[3]:setPosition(40+33*3,33)
- -- m.selectors[4]:setPosition(40+33*4,33)
+ m = Menu:new()
+ m:newSelector()
+ m:newSelector()
+ m:newSelector()
+ m:newSelector()
-- Controllers
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])
+ m:assignController(Controllers[1])
+ m:assignController(Controllers[2])
- -- Menu Controllers
- -- m:assignController(Controllers[1])
- -- m:assignController(Controllers[2])
+ -- ZU WARUDO!
+ -- w = World:new("default", {"leon", Controllers[1]}, {"lonestar", Controllers[2]})
end
-- Update
function love.update (dt)
- w:update(dt)
- -- m:update(dt)
+ -- w:update(dt)
+ m:update(dt)
end
-- KeyPressed
@@ -68,11 +58,12 @@ function love.keypressed (key)
love.event.quit()
end
if key == "f5" and debug then
- local new = World:new("default", "leon", "lonestar", third, fourth)
- w = nil
- w = new
- w.Nauts[1]:assignController(cont1)
- w.Nauts[2]:assignController(cont2)
+ local new = World:new("default", {"leon", Controllers[1]}, {"lonestar", Controllers[2]})
+ m = nil
+ m = new
+ end
+ if key == "f6" then
+ m = m:startGame()
end
end
@@ -86,8 +77,8 @@ end
-- Draw
function love.draw ()
- w:draw()
- -- m:draw()
+ -- w:draw()
+ m:draw()
if debug then
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
end
diff --git a/menu.lua b/menu.lua
index 2e15881..6f0681c 100644
--- a/menu.lua
+++ b/menu.lua
@@ -69,6 +69,9 @@ function Menu:update(dt)
else
self.countdown = 3
end
+ if state and self.countdown < 0 then
+ self.__index = self:startGame()
+ end
end
--
@@ -105,4 +108,14 @@ end
-- It just must be here
function Menu:controllerReleased(control, controller)
+end
+
+-- WARUDO
+function Menu:startGame()
+ local nauts = {}
+ for _,selector in pairs(self.selected) do
+ table.insert(nauts, {selector:getSelectionName(), selector:getController()})
+ end
+ local world = World:new("default", nauts)
+ return world
end \ No newline at end of file
diff --git a/selector.lua b/selector.lua
index 8d1ef78..81e8d19 100644
--- a/selector.lua
+++ b/selector.lua
@@ -45,6 +45,9 @@ function Selector:clear()
self.naut = 1
self.state = false
end
+function Selector:getSelectionName()
+ return self.parent.nauts[self.naut]
+end
function Selector:controllerPressed(control, controller)
local n = #self.parent.nauts
if control == "left" and not self.state then
diff --git a/world.lua b/world.lua
index 86ba1e3..c11855d 100644
--- a/world.lua
+++ b/world.lua
@@ -75,10 +75,17 @@ end
-- Spawn all the nauts for the round
function World:spawnNauts(...)
- local nauts = {...}
+ local params = {...}
+ local nauts = nil
+ if type(params[1][1]) == "table" then
+ nauts = params[1]
+ else
+ nauts = params
+ end
for _,naut in pairs(nauts) do
local x,y = self:getSpawnPosition()
- self:createNaut(x, y, naut)
+ local spawn = self:createNaut(x, y, naut[1])
+ spawn:assignController(naut[2])
end
end
@@ -95,7 +102,9 @@ end
-- Add new naut to the world
function World:createNaut(x, y, name)
- table.insert(self.Nauts, Player:new(self, self.world, x, y, name))
+ local naut = Player:new(self, self.world, x, y, name)
+ table.insert(self.Nauts, naut)
+ return naut
end
-- Add new cloud to the world