summaryrefslogtreecommitdiffhomepage
path: root/player.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-15 01:49:29 +0200
committerAki <nthirtyone@gmail.com>2016-08-15 01:49:29 +0200
commitba2d5c2f30c5846220f1d1570d0d19dca0a61814 (patch)
treea3912761fe24c26b58ca656011ee02f8c6291c54 /player.lua
parent0e785f506b070b1dcd5587cc0641313daaa6e53b (diff)
downloadroflnauts-ba2d5c2f30c5846220f1d1570d0d19dca0a61814.zip
roflnauts-ba2d5c2f30c5846220f1d1570d0d19dca0a61814.tar.gz
roflnauts-ba2d5c2f30c5846220f1d1570d0d19dca0a61814.tar.bz2
quicksave
Diffstat (limited to 'player.lua')
-rw-r--r--player.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/player.lua b/player.lua
index fe11dbe..7d9d35c 100644
--- a/player.lua
+++ b/player.lua
@@ -37,6 +37,10 @@ Player = {
jumpdouble = true,
jumptimer = 0.16,
jumpnumber = 2,
+ down_left = false,
+ down_right = false,
+ down_up = false,
+ down_down = false,
-- Keys
controlset = nil,
-- HUD
@@ -82,7 +86,7 @@ end
-- Control set managment
function Player:assignControlSet(set)
- self.controlset = set or nil
+ self.controlset = set
end
function Player:getControlSet()
return self.controlset
@@ -93,13 +97,11 @@ function Player:update(dt)
-- hotfix? for destroyed bodies
if self.body:isDestroyed() then return end
-- # LOCALS
- -- velocity: x, y
local x,y = self.body:getLinearVelocity()
-
+ print(Controller.isDown(self:getControlSet(), "left"))
-- # VERTICAL MOVEMENT
-- Jumping
if self.jumpactive and self.jumptimer > 0 then
- local x,y = self.body:getLinearVelocity()
self.body:setLinearVelocity(x,-160)
self.jumptimer = self.jumptimer - dt
end
@@ -342,7 +344,7 @@ end
-- Punch of `Player`
-- offset_x, offset_y, step_x, step_y, vector_x, vector_y
-function Player:hit (ox, oy, sx, sy, vx, vy)
+function Player:hit(ox, oy, sx, sy, vx, vy)
-- start cooldown
self.punchcd = self.punchinitial
-- actual punch
@@ -359,7 +361,7 @@ end
-- Hittest
-- Should be replaced with actual sensor; after moving collision callbacks into Player
-function Player:testHit (target, ox, oy, sx, sy)
+function Player:testHit(target, ox, oy, sx, sy)
local x, y = self.body:getPosition()
for v=0,2 do
for h=0,2,1+v%2 do
@@ -370,7 +372,7 @@ function Player:testHit (target, ox, oy, sx, sy)
end
-- Taking damage of `Player` by successful hit test
-function Player:damage (horizontal, vertical)
+function Player:damage(horizontal, vertical)
self:createEffect("hit")
local x,y = self.body:getLinearVelocity()
self.body:setLinearVelocity(x,0)
@@ -382,7 +384,7 @@ function Player:damage (horizontal, vertical)
end
-- DIE
-function Player:die ()
+function Player:die()
self:playSound(1)
self.combo = Player.combo
self.lives = self.lives - 1
@@ -393,7 +395,7 @@ function Player:die ()
end
-- And then respawn. Like Jon Snow.
-function Player:respawn ()
+function Player:respawn()
self.alive = true
self.body:setLinearVelocity(0,0)
self.body:setPosition(self.world:getSpawnPosition())