diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-29 13:17:54 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-29 13:17:54 +0200 |
commit | 6d61fb66d72bb668d71479d3ed5f40b51041639e (patch) | |
tree | 93091a80f6ec117bd2185544fd425473eecc5b1e /not/Player.lua | |
parent | 356054d6dc0fffc280e893ec4385559b4c618de2 (diff) | |
download | roflnauts-6d61fb66d72bb668d71479d3ed5f40b51041639e.zip roflnauts-6d61fb66d72bb668d71479d3ed5f40b51041639e.tar.gz roflnauts-6d61fb66d72bb668d71479d3ed5f40b51041639e.tar.bz2 |
Moved update part of jumping from Player to Hero
isJumping is now a method
added debugging information on player jumps
Diffstat (limited to 'not/Player.lua')
-rw-r--r-- | not/Player.lua | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/not/Player.lua b/not/Player.lua index 0b56e6d..3d15f31 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -25,16 +25,8 @@ function Player:isControlDown (control) return Controller.isDown(self:getControllerSet(), control) end --- Update of `Player`. -function Player:update (dt) - 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. - if self.isJumping and self.jumpTimer > 0 then - self:setLinearVelocity(x,-160) - self.jumpTimer = self.jumpTimer - dt - end +function Player:isJumping () + return self:isControlDown("jump") end function Player:isWalkingLeft () @@ -51,10 +43,9 @@ function Player:controlpressed (set, action, key) self.smoke = false -- TODO: temporary -- Jumping if action == "jump" then + self.jumpCounter = self.jumpCounter - 1 if self.jumpCounter > 0 then - -- General jump logics - self.isJumping = true - --self:playSound(6) + -- self:playSound(6) -- Spawn proper effect if not self.inAir then self:createEffect("jump") @@ -71,8 +62,6 @@ function Player:controlpressed (set, action, key) (self.current == self.animations.attack_down) then self:setAnimation("default") end - -- Remove jump - self.jumpCounter = self.jumpCounter - 1 end end @@ -118,7 +107,6 @@ function Player:controlreleased (set, action, key) if set ~= self:getControllerSet() then return end -- Jumping if action == "jump" then - self.isJumping = false self.jumpTimer = Hero.jumpTimer -- take initial from metatable end -- Walking |