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/Hero.lua | 19 +++++++------------ not/Player.lua | 1 - 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/not/Hero.lua b/not/Hero.lua index ff07c36..d9b0636 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -3,8 +3,6 @@ -- Collision category: [2] Hero = require "not.PhysicalBody":extends() --- Combat -Hero.punchdir = 0 -- a really bad thing -- Movement Hero.jumpTimer = 0.16 Hero.jumpCounter = 2 @@ -127,17 +125,14 @@ function Hero:update (dt) end -- Stop vertical - local c,a = self.current, self.animations - if (c == a.attack_up or c == a.attack_down or c == a.attack) and self.frame < c.frames then - if self.punchdir == 0 then - self:setLinearVelocity(0,0) - else - self:setLinearVelocity(38*self.facing,0) + local currentAnimation = self:getAnimation() + if self.frame < currentAnimation.frames then + if currentAnimation == self.animations.attack_up or currentAnimation == self.animations.attack_down then + self:setLinearVelocity(0, 0) + end + if currentAnimation == self.animations.attack then + self:setLinearVelocity(38*self.facing, 0) end - end - - if self.punchCooldown <= 0 and self.punchdir == 1 then - self.punchdir = 0 end end 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