summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-08 13:31:20 +0200
committerAki <nthirtyone@gmail.com>2016-08-08 13:31:20 +0200
commit16a54ae01e5a025d47d95d6ed24835b0ac227ab5 (patch)
treed335fbb8daa8b012fe6b6f4c50a14d9757181667
parent1bf857aa6e760089534bec5c17783d74f035d983 (diff)
downloadroflnauts-16a54ae01e5a025d47d95d6ed24835b0ac227ab5.zip
roflnauts-16a54ae01e5a025d47d95d6ed24835b0ac227ab5.tar.gz
roflnauts-16a54ae01e5a025d47d95d6ed24835b0ac227ab5.tar.bz2
Combo, lives, respawn tweaks
-rw-r--r--player.lua25
1 files changed, 14 insertions, 11 deletions
diff --git a/player.lua b/player.lua
index db6a683..d1ce62e 100644
--- a/player.lua
+++ b/player.lua
@@ -18,9 +18,9 @@ Player = {
max_velocity = 105,
world = nil, -- game world
-- Combat
- combo = 1,
+ combo = 0,
lives = 3,
- spawntimer = 0,
+ spawntimer = 2,
alive = true,
punchcd = 0,
punchinitial = 0.25,
@@ -317,11 +317,14 @@ end
-- Draw HUD of `Player`
-- elevation: 1 bottom, 0 top
function Player:drawHUD (x,y,scale,elevation)
- love.graphics.setColor(255,255,255,255)
- love.graphics.draw(self.portrait_sprite, self.portrait_sheet[self.name].normal, x*scale, y*scale, 0, scale, scale)
- local dy = 30 * elevation
- love.graphics.print(self.combo.."0%",(x+2)*scale,(y-3+dy)*scale,0,scale,scale)
- love.graphics.print(math.max(0, self.lives),(x+24)*scale,(y-3+dy)*scale,0,scale,scale)
+ -- hud displays only if player is alive
+ if self.alive then
+ love.graphics.setColor(255,255,255,255)
+ love.graphics.draw(self.portrait_sprite, self.portrait_sheet[self.name].normal, x*scale, y*scale, 0, scale, scale)
+ local dy = 30 * elevation
+ love.graphics.print((self.combo*10).."%",(x+2)*scale,(y-3+dy)*scale,0,scale,scale)
+ love.graphics.print(math.max(0, self.lives),(x+24)*scale,(y-3+dy)*scale,0,scale,scale)
+ end
end
-- Change animation of `Player`
@@ -379,18 +382,18 @@ function Player:damage (horizontal, vertical)
self.body:setLinearVelocity(x,0)
self.body:applyLinearImpulse((42+10*self.combo)*horizontal, (68+10*self.combo)*vertical + 15)
self:changeAnimation("damage")
- self.combo = math.min(80, self.combo + 1)
- self.punchcd = 0.07 + self.combo*0.005
+ self.combo = math.min(27, self.combo + 1)
+ self.punchcd = 0.08 + self.combo*0.006
self:playSound(2)
end
-- DIE
function Player:die ()
self:playSound(1)
- self.combo = 1
+ self.combo = Player.combo
self.lives = self.lives - 1
self.alive = false
- self.spawntimer = 1
+ self.spawntimer = Player.spawntimer
self.body:setActive(false)
self.world:onNautKilled(self)
end