diff options
Diffstat (limited to 'not')
-rw-r--r-- | not/Hero.lua | 15 | ||||
-rw-r--r-- | not/Selector.lua | 11 | ||||
-rw-r--r-- | not/World.lua | 2 |
3 files changed, 18 insertions, 10 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) diff --git a/not/Selector.lua b/not/Selector.lua index ee6f0e3..5536b44 100644 --- a/not/Selector.lua +++ b/not/Selector.lua @@ -100,6 +100,12 @@ function Selector:getText () return tostring(self:getSelected()) end +function Selector:getIcon () + if self.icons then + return self.icons[self.index] + end +end + function Selector:focus () self.focused = true return true @@ -134,8 +140,9 @@ function Selector:draw (scale) end love.graphics.draw(self.atlas, self.quads[self:getShapeString()][boxType], x*scale, y*scale, 0, scale, scale) -- TODO: That is one way to draw icon for selected value. Find better one. See: `config/menus/host`. - if self.icons_atlas and self.icons_quads then - love.graphics.draw(self.icons_atlas, self.icons_quads[self.index], (x+2)*scale, (y+3)*scale, 0, scale, scale) + local icon = self:getIcon() + if icon then + love.graphics.draw(icon, (x+2)*scale, (y+3)*scale, 0, scale, scale) end love.graphics.setColor(255, 255, 255, 255) diff --git a/not/World.lua b/not/World.lua index 4523efa..6bc5e18 100644 --- a/not/World.lua +++ b/not/World.lua @@ -468,7 +468,7 @@ function World:controlpressed (set, action, key) map.filename = filename local nauts = {} for _,naut in pairs(self:getNautsAll()) do - table.insert(nauts, {naut.name, naut:getControllerSet()}) + table.insert(nauts, {naut.config, naut:getControllerSet()}) end local new = World(map, nauts) sceneManager:changeScene(new) |