diff options
Diffstat (limited to 'not/Hero.lua')
-rw-r--r-- | not/Hero.lua | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/not/Hero.lua b/not/Hero.lua index 66bc511..a97a2b1 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -8,7 +8,6 @@ Hero.jumpTimer = 0.16 Hero.jumpCounter = 2 Hero.sfx = require "config.sounds" -Hero.QUAD_PORTRAITS = getNautsIconsList() Hero.QUAD_FRAME = love.graphics.newQuad(0, 15, 32,32, 80,130) Hero.IMAGE_PORTRAITS = nil Hero.IMAGE_FRAME = nil @@ -21,9 +20,10 @@ Hero.PUNCH_RIGHT = {2,-6, 20,-6, 20,6, 2,6} Hero.PUNCH_UP = {-8,-4, -8,-20, 8,-20, 8,-4} Hero.PUNCH_DOWN = {-8,4, -8,20, 8,20, 8,4} --- Constructor of `Hero`. -function Hero:new (name, x, y, world) - local imagePath = string.format("assets/nauts/%s.png", name) +-- TODO: Portrait managment in Hero and config passed from Menu should be reviewed! +-- TODO: Clean-up, see `menus/select`. +function Hero:new (config, x, y, world) + local imagePath = config.image Hero.load() Hero.__super.new(self, x, y, world, imagePath) -- Physics @@ -32,8 +32,8 @@ function Hero:new (name, x, y, world) self:setBodyFixedRotation(true) self:newFixture() -- General + self.config = config self.world = world - self.name = name self.angle = 0 self.facing = 1 -- Status @@ -47,6 +47,8 @@ function Hero:new (name, x, y, world) self.isJumping = false self.spawntimer = 2 self.punchCooldown = 0 + -- TODO: Pass loaded portrait from menu to Hero. + self.portrait = love.graphics.newImage(config.portrait) self:setAnimationsList(require("config.animations.hero")) -- Post-creation self:createEffect("respawn") @@ -55,7 +57,6 @@ end -- TODO: This is temporarily called by constructor. function Hero.load () if Hero.IMAGE_PORTRAITS == nil then - Hero.IMAGE_PORTRAITS = love.graphics.newImage("assets/portraits.png") Hero.IMAGE_FRAME = love.graphics.newImage("assets/menu.png") end end @@ -185,7 +186,7 @@ function Hero:drawHUD (x,y,scale,elevation) if self.isAlive then love.graphics.setColor(255,255,255,255) love.graphics.draw(self.IMAGE_FRAME, self.QUAD_FRAME, (x)*scale, (y)*scale, 0, scale, scale) - love.graphics.draw(self.IMAGE_PORTRAITS, self.QUAD_PORTRAITS[self.name], (x+2)*scale, (y+3)*scale, 0, scale, scale) + love.graphics.draw(self.portrait, (x+2)*scale, (y+3)*scale, 0, scale, scale) local dy = 30 * elevation love.graphics.setFont(Font) love.graphics.print((self.combo).."%",(x+2)*scale,(y-3+dy)*scale,0,scale,scale) |