summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-24 14:19:18 +0200
committerAki <nthirtyone@gmail.com>2016-08-24 14:19:18 +0200
commit8b0698abc1290cbdbfef3c8b48a2dc7a0388c9d1 (patch)
treea135f4198502c8615379763788bcc4f254dfc29f
parent1213e1e2831805ebb5d193702e02c59c2927e54a (diff)
downloadroflnauts-8b0698abc1290cbdbfef3c8b48a2dc7a0388c9d1.zip
roflnauts-8b0698abc1290cbdbfef3c8b48a2dc7a0388c9d1.tar.gz
roflnauts-8b0698abc1290cbdbfef3c8b48a2dc7a0388c9d1.tar.bz2
Blink button, fix empty error
-rw-r--r--button.lua14
-rw-r--r--config/menuselect.lua7
-rw-r--r--selector.lua9
-rw-r--r--world.lua13
4 files changed, 27 insertions, 16 deletions
diff --git a/button.lua b/button.lua
index fd12e0b..6b8ef25 100644
--- a/button.lua
+++ b/button.lua
@@ -11,6 +11,7 @@ Button = {
arrow_l = love.graphics.newQuad(58, 0, 5, 5, 68,15),
arrow_r = love.graphics.newQuad(63, 0, 5, 5, 68,15),
delay = 2,
+ blinker = 1,
parent
}
@@ -40,6 +41,9 @@ function Button:blur()
self.focused = false
end
function Button:active() end
+function Button:blink()
+ self.blinker = 0
+end
function Button:set(name, func)
if type(name) == "string" and type(func) == "function" then
self[name] = func
@@ -48,7 +52,12 @@ function Button:set(name, func)
end
function Button:draw(scale)
local x,y = self:getPosition()
- love.graphics.setColor(255, 255, 255, 255)
+ local blinker = math.floor(self.blinker*4)
+ if blinker%2 == 0 then
+ love.graphics.setColor(255, 255, 255, 255)
+ else
+ love.graphics.setColor(255, 100, 100, 255)
+ end
love.graphics.draw(self.sprite, self.quad, x*scale, y*scale, 0, scale, scale)
if self.focused then
love.graphics.draw(self.sprite, self.arrow_l, (x+54+math.floor(self.delay))*scale, (y+5)*scale, 0, scale, scale)
@@ -62,6 +71,9 @@ function Button:update(dt)
if self.delay > Button.delay then -- Button.delay is initial
self.delay = self.delay - Button.delay
end
+ if self.blinker < Button.blinker then -- Button.blink is initial
+ self.blinker = self.blinker + dt
+ end
end
function Button:controlpressed(set, action, key)
if action == "attack" and self.focused then
diff --git a/config/menuselect.lua b/config/menuselect.lua
index 8d646ba..c3a05c1 100644
--- a/config/menuselect.lua
+++ b/config/menuselect.lua
@@ -23,7 +23,12 @@ return {
:setText("Force start")
:setPosition(bx,101)
:set("active", function (self)
- changeScene(World:new(nil,naut_selector:getFullSelection(false)))
+ local nauts = naut_selector:getFullSelection(false)
+ if #nauts > 1 then
+ changeScene(World:new(nil, nauts))
+ else
+ self:blink()
+ end
end)
,
button:new(menu)
diff --git a/selector.lua b/selector.lua
index 0b3fe8a..cba01e6 100644
--- a/selector.lua
+++ b/selector.lua
@@ -144,13 +144,14 @@ end
-- Get list of selections, checks if not locked are allowed.
function Selector:getFullSelection(allowed)
- local allowed = allowed or false
+ local allowed = allowed
+ if allowed == nil then allowed = false end
local t = {}
- for n,v in ipairs(self.selections) do
+ for n,v in pairs(self.selections) do
local name = self:getListValue(self:getSelection(n))
local locked = self:isLocked(n)
- if not (not locked and not allow) then
- table.insert(t, {name, self.sets[n], self:isLocked(n)})
+ if locked or allowed then
+ table.insert(t, {name, self.sets[n]})
end
end
return t
diff --git a/world.lua b/world.lua
index 8f948ce..57b8cd7 100644
--- a/world.lua
+++ b/world.lua
@@ -36,7 +36,7 @@ World = {
}
-- Constructor of `World` ZA WARUDO!
-function World:new(map, ...)
+function World:new(map, nauts)
-- Meta
local o = {}
setmetatable(o, self)
@@ -64,7 +64,7 @@ function World:new(map, ...)
local map = map or "default"
o:loadMap(map)
-- Nauts
- o:spawnNauts(...)
+ o:spawnNauts(nauts)
-- Create camera
o.camera = Camera:new(o)
-- Play music
@@ -110,14 +110,7 @@ function World:loadMap(name)
end
-- Spawn all the nauts for the round
-function World:spawnNauts(...)
- local params = {...}
- local nauts = nil
- if type(params[1][1]) == "table" then
- nauts = params[1]
- else
- nauts = params
- end
+function World:spawnNauts(nauts)
for _,naut in pairs(nauts) do
local x,y = self:getSpawnPosition()
local spawn = self:createNaut(x, y, naut[1])