diff options
-rw-r--r-- | button.lua | 14 | ||||
-rw-r--r-- | config/menuselect.lua | 7 | ||||
-rw-r--r-- | selector.lua | 9 | ||||
-rw-r--r-- | world.lua | 13 |
4 files changed, 27 insertions, 16 deletions
@@ -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 @@ -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]) |