From ab54b33e5ba43440c83bcd405fadad835a9e6450 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 5 Jun 2016 16:50:29 +0200 Subject: Menu visuals --- assets/font3.png | Bin 0 -> 941 bytes main.lua | 1 + menu.lua | 14 ++++++++++---- portraits.lua | 5 ++++- selector.lua | 15 +++++++++++++-- 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 assets/font3.png diff --git a/assets/font3.png b/assets/font3.png new file mode 100644 index 0000000..2221d88 Binary files /dev/null and b/assets/font3.png differ diff --git a/main.lua b/main.lua index c728606..198e8b5 100644 --- a/main.lua +++ b/main.lua @@ -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) diff --git a/menu.lua b/menu.lua index 72c2087..d18e149 100644 --- a/menu.lua +++ b/menu.lua @@ -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) -- cgit v1.1