diff options
author | Aki <nthirtyone@gmail.com> | 2016-06-05 16:50:29 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-06-05 16:50:29 +0200 |
commit | ab54b33e5ba43440c83bcd405fadad835a9e6450 (patch) | |
tree | 81d9affd3bee13571b6d3468c4b87f5debfff715 | |
parent | 6a95cb98187127fc2379127b176483d496ef5181 (diff) | |
download | roflnauts-ab54b33e5ba43440c83bcd405fadad835a9e6450.zip roflnauts-ab54b33e5ba43440c83bcd405fadad835a9e6450.tar.gz roflnauts-ab54b33e5ba43440c83bcd405fadad835a9e6450.tar.bz2 |
Menu visuals
-rw-r--r-- | assets/font3.png | bin | 0 -> 941 bytes | |||
-rw-r--r-- | main.lua | 1 | ||||
-rw-r--r-- | menu.lua | 14 | ||||
-rw-r--r-- | portraits.lua | 5 | ||||
-rw-r--r-- | selector.lua | 15 |
5 files changed, 28 insertions, 7 deletions
diff --git a/assets/font3.png b/assets/font3.png Binary files differnew file mode 100644 index 0000000..2221d88 --- /dev/null +++ b/assets/font3.png @@ -23,6 +23,7 @@ function love.load () -- Font Font = love.graphics.newImageFont("assets/font2.png", " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-,!:()[]{}<>", -1) + Bold = love.graphics.newImageFont("assets/font3.png", " 0123456789", 0) Font:setLineHeight(1) love.graphics.setFont(Font) @@ -16,7 +16,7 @@ Menu = { portrait_sprite = nil, portrait_sheet = require "portraits", scale = 4, - countdown = 3 + countdown = 6 } -- Constructor of `Menu` @@ -39,7 +39,7 @@ function Menu:newSelector() local w, h = love.graphics.getWidth()/self.scale, love.graphics.getHeight()/self.scale local n = #self.selectors - 1 table.insert(self.selectors, selector) - local x = (w-79)/2+n*38 + local x = (w-76)/2+n*44 local y = h/2-16 selector:setPosition(x, y) end @@ -52,7 +52,13 @@ function Menu:draw() for _,selector in pairs(self.selected) do selector:draw() end - love.graphics.print(self.countdown,2,2,0,self.scale,self.scale) + local countdown, _ = math.modf(self.countdown) + local w, h = love.graphics.getWidth()/self.scale, love.graphics.getHeight()/self.scale + if self.countdown < 6 then + love.graphics.setFont(Bold) + love.graphics.print(countdown,(w/2-6.5)*self.scale,(h/2+20)*self.scale,0,2,2) + love.graphics.setFont(Font) + end end function Menu:update(dt) @@ -67,7 +73,7 @@ function Menu:update(dt) if state then self.countdown = self.countdown - dt else - self.countdown = 3 + self.countdown = 6 end if state and self.countdown < 0 then self:startGame() diff --git a/portraits.lua b/portraits.lua index 1f79e9e..2df9837 100644 --- a/portraits.lua +++ b/portraits.lua @@ -118,5 +118,8 @@ return { ix = { normal = love.graphics.newQuad(265,133,32,32,w,h), active = love.graphics.newQuad(265,166,32,32,w,h) - } + }, + -- ARROWS + arrow_left = love.graphics.newQuad(298,1,4,6,w,h), + arrow_right = love.graphics.newQuad(303,1,4,6,w,h) }
\ No newline at end of file diff --git a/selector.lua b/selector.lua index 5a1cb22..97a20c6 100644 --- a/selector.lua +++ b/selector.lua @@ -23,12 +23,23 @@ function Selector:getPosition () return self.x, self.y end function Selector:draw () + -- portrait, sprite local p = self.parent.portrait_sheet[self.parent.nauts[self.naut]] + local sprite = self.parent.portrait_sprite + -- scale, position local scale = self.parent.scale + local x,y = self:getPosition() + -- arrows + local arrowl = self.parent.portrait_sheet.arrow_left + local arrowr = self.parent.portrait_sheet.arrow_right if not self.state then - love.graphics.draw(self.parent.portrait_sprite, p.normal, self.x*scale, self.y*scale, 0, 1*scale, 1*scale) + love.graphics.draw(sprite, p.normal, x*scale, y*scale, 0, 1*scale, 1*scale) + if self.controller ~= nil then + love.graphics.draw(sprite, arrowl, (x-5)* scale, (y+13)*scale, 0, scale, scale) + love.graphics.draw(sprite, arrowr, (x+33)*scale, (y+13)*scale, 0, scale, scale) + end else - love.graphics.draw(self.parent.portrait_sprite, p.active, self.x*scale, self.y*scale, 0, 1*scale, 1*scale) + love.graphics.draw(sprite, p.active, x*scale, y*scale, 0, 1*scale, 1*scale) end end function Selector:assignController(controller) |