From 482797c1feab2b238822202593c1964c648d4198 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 21 May 2016 20:35:47 +0200 Subject: HUD combo/lives --- assets/font2.png | Bin 0 -> 3456 bytes main.lua | 7 ++++++- player.lua | 7 ++++++- world.lua | 7 +++---- 4 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 assets/font2.png diff --git a/assets/font2.png b/assets/font2.png new file mode 100644 index 0000000..ea6a58e Binary files /dev/null and b/assets/font2.png differ diff --git a/main.lua b/main.lua index 5febe09..8d9a9df 100644 --- a/main.lua +++ b/main.lua @@ -10,7 +10,7 @@ require "effect" -- Temporary debug debug = false -third = false +third = true fourth = false -- Load @@ -19,6 +19,11 @@ function love.load () love.graphics.setBackgroundColor(189, 95, 93) love.graphics.setDefaultFilter("nearest", "nearest") + -- Font + Font = love.graphics.newImageFont("assets/font2.png", " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-,!:()[]{}<>", -1) + Font:setLineHeight(1) + love.graphics.setFont(Font) + -- ZU WARUDO! w = World:new() w:createPlatform(290/2, 180/2, {-91,1, 90,1, 90,10, 5,76, -5,76, -91,10}, "assets/platform_big.png") diff --git a/player.lua b/player.lua index bb30f21..abaf37d 100644 --- a/player.lua +++ b/player.lua @@ -271,8 +271,13 @@ function Player:draw (offset_x, offset_y, scale, debug) end -- Draw HUD of `Player` -function Player:drawHUD (x,y,scale) +-- elevation: 1 bottom, 0 top +function Player:drawHUD (x,y,scale,elevation) + love.graphics.setColor(255,255,255,255) love.graphics.draw(self.portrait_sprite, self.portrait_sheet[self.name].normal, x*scale, y*scale, 0, scale, scale) + local dy = 30 * elevation + love.graphics.print(self.combo.."0x",(x+2)*scale,(y-3+dy)*scale,0,scale,scale) + love.graphics.print(math.max(0, self.lives),(x+24)*scale,(y-3+dy)*scale,0,scale,scale) end -- Change animation of `Player` diff --git a/world.lua b/world.lua index 56b67be..d896f18 100644 --- a/world.lua +++ b/world.lua @@ -173,10 +173,9 @@ function World:draw() for _,naut in pairs(self.Nauts) do -- I have no idea where to place them T_T -- let's do: bottom-left, bottom-right, top-left, top-right - -- equation that gives 0 with 1,2 and 1 with 3,4 -- fffs lets make statement - local y = 1 - if _ < 3 then y = 180-33 end - naut:drawHUD(1+(_%2)*(290-34), y, scale) + local y, e = 1, 1 + if _ < 3 then y, e = 180-33, 0 end + naut:drawHUD(1+(_%2)*(290-34), y, scale, e) end end -- cgit v1.1