From 62b67be7882dffebd6de0c8241d253d806a6905c Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 26 May 2017 19:14:27 +0200 Subject: Halfway through with moving to new OOP module --- not/Player.lua | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'not/Player.lua') diff --git a/not/Player.lua b/not/Player.lua index 2a4b2e6..5d108ce 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -1,31 +1,15 @@ +require "not.Hero" + --- `Player` -- Special `not.Hero` controllable by a player. -Player = { - -- TODO: move functions and properties related to controls from `not.Hero`. - controllerSet = --[[Controller.sets.*]]nil, -} +-- TODO: move functions and properties related to controls from `not.Hero`. +Player = Hero:extends() --- `Player` is a child of `Hero`. -require "not.Hero" -Player.__index = Player -setmetatable(Player, Hero) +Player.controllerSet =--[[Controller.sets.*]]nil -- Constructor of `Player`. -function Player:new (name, game, x, y) - local o = setmetatable({}, self) - o:init(name, game, x, y) - -- Load portraits statically to `not.Hero`. - -- TODO: this is heresy, put it into `load` method or something similar. - if Hero.portrait_sprite == nil then - Hero.portrait_sprite = love.graphics.newImage("assets/portraits.png") - Hero.portrait_frame = love.graphics.newImage("assets/menu.png") - end - return o -end - --- Initializer of `Player`. -function Player:init (...) - Hero.init(self, ...) +function Player:new (name, x, y, world) + Player.__super.new(self, name, x, y, world) end -- Controller set manipulation. @@ -43,7 +27,7 @@ end -- Update of `Player`. function Player:update (dt) - Hero.update(self, dt) -- TODO: It would be probably a good idea to add return to update functions to terminate if something goes badly in parent's update. + Player.__super.update(self, dt) -- TODO: It would be probably a good idea to add return to update functions to terminate if something goes badly in parent's update. if self.body:isDestroyed() then return end local x, y = self:getLinearVelocity() -- Jumping. @@ -157,3 +141,5 @@ function Player:controlreleased (set, action, key) end end end + +return Player -- cgit v1.1 From b5c3f635128845baa6fdc738df44c5fe88b3db82 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 28 Jun 2017 21:18:09 +0200 Subject: Fixed animation bug for Player on walking combination --- not/Player.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'not/Player.lua') diff --git a/not/Player.lua b/not/Player.lua index 5d108ce..34f57eb 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -134,10 +134,11 @@ function Player:controlreleased (set, action, key) end -- Walking if (action == "left" or action == "right") then - self.isWalking = false - if not (self:isControlDown("left") or self:isControlDown("right")) and - self.current == self.animations.walk then - self:setAnimation("default") + if not (self:isControlDown("left") or self:isControlDown("right")) then + self.isWalking = false + if self.current == self.animations.walk then + self:setAnimation("default") + end end end end -- cgit v1.1 From 113d648178755dd0fb9f4ea0e7726f173ecc5223 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 16 Jul 2017 23:45:35 +0200 Subject: Cleaning-up Hero and Player, this far w/o big changes --- not/Player.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'not/Player.lua') diff --git a/not/Player.lua b/not/Player.lua index 34f57eb..8e15da0 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -41,7 +41,7 @@ function Player:update (dt) self.facing = -1 self:applyForce(-250, 0) -- Controlled speed limit - if x < -self.max_velocity then + if x < -self.MAX_VELOCITY then self:applyForce(250, 0) end end @@ -49,7 +49,7 @@ function Player:update (dt) self.facing = 1 self:applyForce(250, 0) -- Controlled speed limit - if x > self.max_velocity then + if x > self.MAX_VELOCITY then self:applyForce(-250, 0) end end -- cgit v1.1 From fc43bcb81b5dbfc8ef8dd164193014aa0cf43c9f Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 17 Jul 2017 12:53:00 +0200 Subject: Trail now works mostly as intended --- not/Player.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'not/Player.lua') diff --git a/not/Player.lua b/not/Player.lua index 8e15da0..11461d3 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -58,6 +58,7 @@ end -- Controller callbacks. function Player:controlpressed (set, action, key) if set ~= self:getControllerSet() then return end + self.smoke = false -- TODO: temporary -- Jumping if action == "jump" then if self.jumpCounter > 0 then -- cgit v1.1 From b6aad58259b1e71913280d30e2c9dbf4ecf264c3 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 18 Jul 2017 06:39:05 +0200 Subject: Removed obsolete punchdir and reworked physical animations on punches --- not/Player.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'not/Player.lua') diff --git a/not/Player.lua b/not/Player.lua index 11461d3..b0dac75 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -122,7 +122,6 @@ function Player:controlpressed (set, action, key) else self:punch("left") end - self.punchdir = 1 end end end -- cgit v1.1