From dd9245c6b22f756bc439960afabf5793634c45f5 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 22 Sep 2017 01:32:45 +0200 Subject: Split nauts.lua into several files now used by Hero and Menu --- not/Hero.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'not') diff --git a/not/Hero.lua b/not/Hero.lua index 66bc511..a735107 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,9 @@ 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! +function Hero:new (config, x, y, world) + local imagePath = config.image Hero.load() Hero.__super.new(self, x, y, world, imagePath) -- Physics @@ -33,7 +32,7 @@ function Hero:new (name, x, y, world) self:newFixture() -- General self.world = world - self.name = name + self.name = config.name self.angle = 0 self.facing = 1 -- Status @@ -47,6 +46,7 @@ function Hero:new (name, x, y, world) self.isJumping = false self.spawntimer = 2 self.punchCooldown = 0 + self.portrait = love.graphics.newQuad((config.portrait-1)*28, 0, 28, 27, 1176, 27) self:setAnimationsList(require("config.animations.hero")) -- Post-creation self:createEffect("respawn") @@ -185,7 +185,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.IMAGE_PORTRAITS, 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) -- cgit v1.1 From 1a4db161e7be614e002c4f8edccbf3acf1edc6aa Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 22 Sep 2017 15:00:31 +0200 Subject: Changed portrait quad property name in Hero --- not/Hero.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'not') diff --git a/not/Hero.lua b/not/Hero.lua index a735107..2549b18 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -46,7 +46,7 @@ function Hero:new (config, x, y, world) self.isJumping = false self.spawntimer = 2 self.punchCooldown = 0 - self.portrait = love.graphics.newQuad((config.portrait-1)*28, 0, 28, 27, 1176, 27) + self.portraitQuad = love.graphics.newQuad((config.portrait-1)*28, 0, 28, 27, 1176, 27) self:setAnimationsList(require("config.animations.hero")) -- Post-creation self:createEffect("respawn") @@ -185,7 +185,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.portrait, (x+2)*scale, (y+3)*scale, 0, scale, scale) + love.graphics.draw(self.IMAGE_PORTRAITS, self.portraitQuad, (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) -- cgit v1.1 From 2235ec2648258bdf51c75280b2289cea0c970d0f Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 22 Sep 2017 18:02:23 +0200 Subject: Added getIcon for Selector --- not/Selector.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'not') 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) -- cgit v1.1 From 70cd74d62d0f6d1c389a3a3ef333acb578713727 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 22 Sep 2017 18:02:42 +0200 Subject: Hero now properly uses split-up portraits --- not/Hero.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'not') diff --git a/not/Hero.lua b/not/Hero.lua index 2549b18..30092bc 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -21,6 +21,7 @@ Hero.PUNCH_UP = {-8,-4, -8,-20, 8,-20, 8,-4} Hero.PUNCH_DOWN = {-8,4, -8,20, 8,20, 8,4} -- 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() @@ -46,7 +47,8 @@ function Hero:new (config, x, y, world) self.isJumping = false self.spawntimer = 2 self.punchCooldown = 0 - self.portraitQuad = love.graphics.newQuad((config.portrait-1)*28, 0, 28, 27, 1176, 27) + -- 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") @@ -185,7 +187,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.portraitQuad, (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) -- cgit v1.1 From b29adf54e26d16ec7f78e9dd865bc1ce807d3f14 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 22 Sep 2017 18:04:52 +0200 Subject: Removed obsolete attempts to load portraits atlas --- not/Hero.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'not') diff --git a/not/Hero.lua b/not/Hero.lua index 30092bc..fc5d840 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -57,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 -- cgit v1.1 From 86c552cab9d245b6d58638179df2ae657ef9a5db Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 22 Sep 2017 18:22:33 +0200 Subject: Hero now holds config for World restart --- not/Hero.lua | 2 +- not/World.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'not') diff --git a/not/Hero.lua b/not/Hero.lua index fc5d840..a97a2b1 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -32,8 +32,8 @@ function Hero:new (config, x, y, world) self:setBodyFixedRotation(true) self:newFixture() -- General + self.config = config self.world = world - self.name = config.name self.angle = 0 self.facing = 1 -- Status 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) -- cgit v1.1