diff options
author | Aki <nthirtyone@gmail.com> | 2018-04-09 20:42:06 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2018-04-09 20:42:06 +0200 |
commit | 3d2dcce88a19798a5b5e2bd563b1fe2dfa1b80d2 (patch) | |
tree | 3876ad2b4a895375962922487467b2f820a702e7 /not | |
parent | 21880f5d084f04f0403301bac53dc9587eea198d (diff) | |
download | roflnauts-3d2dcce88a19798a5b5e2bd563b1fe2dfa1b80d2.zip roflnauts-3d2dcce88a19798a5b5e2bd563b1fe2dfa1b80d2.tar.gz roflnauts-3d2dcce88a19798a5b5e2bd563b1fe2dfa1b80d2.tar.bz2 |
Last clean-ups of Player, I guess
Diffstat (limited to 'not')
-rw-r--r-- | not/Player.lua | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/not/Player.lua b/not/Player.lua index 72d64bb..5da4f5f 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -6,11 +6,8 @@ Player = require "not.Hero":extends() Player.controllerSet =--[[Controller.sets.*]]nil -function Player:new (name, x, y, world) - Player.__super.new(self, name, x, y, world) -end - --- Controller set manipulation. +--- Assigns controller set to Player. +-- @param set one of `Controller.sets` function Player:assignControllerSet (set) self.controllerSet = set end @@ -19,29 +16,34 @@ function Player:getControllerSet () return self.controllerSet end --- Check if control of assigned controller is pressed. +--- Wrapper for checking if passed control is currently pressed. function Player:isControlDown (control) return Controller.isDown(self:getControllerSet(), control) end +--- Overridden from Hero, used by Hero:update. function Player:isJumping () return self:isControlDown("jump") end +--- Overridden from Hero, used by Hero:update. function Player:isWalkingLeft () return self:isControlDown("left") end +--- Overridden from Hero, used by Hero:update. function Player:isWalkingRight () return self:isControlDown("right") end --- Controller callbacks. +--- Called when control is pressed. +-- @param set ControllerSet that owns pressed control +-- @param action action assigned to control +-- @param key parent key of control function Player:controlpressed (set, action, key) if set ~= self:getControllerSet() then return end self.smoke = false -- TODO: temporary - -- Punching if action == "attack" and self.punchCooldown <= 0 then local f = self.facing if self:isControlDown("up") then @@ -58,8 +60,7 @@ function Player:controlpressed (set, action, key) end end -function Player:controlreleased (set, action, key) - if set ~= self:getControllerSet() then return end -end +--- Called when control is released. +function Player:controlreleased (set, action, key) end return Player |