Add hit sfx, and display current HP

This commit is contained in:
Jean-André Santoni 2017-06-25 14:43:05 +02:00
parent aaeb2eaeb6
commit 4e6759c030
3 changed files with 5 additions and 3 deletions

BIN
assets/hit.wav Executable file

Binary file not shown.

View File

@ -25,6 +25,7 @@ function lutro.load()
camera_x = 0
camera_y = 0
gold = 0
hp = 3
lutro.graphics.setBackgroundColor(0, 0, 0)
bg1 = lutro.graphics.newImage("assets/forestbackground.png")
bg2 = lutro.graphics.newImage("assets/foresttrees.png")
@ -37,6 +38,7 @@ function lutro.load()
sfx_coin = lutro.audio.newSource("assets/coin.wav")
sfx_jump = lutro.audio.newSource("assets/jump.wav")
sfx_step = lutro.audio.newSource("assets/step.wav")
sfx_hit = lutro.audio.newSource("assets/hit.wav")
ninja = newNinja()
table.insert(entities, ninja)
@ -74,5 +76,5 @@ function lutro.draw()
lutro.graphics.pop()
lutro.graphics.print("G" .. gold, 3, 1)
lutro.graphics.print("HP " .. hp .. " GOLD " .. gold, 3, 1)
end

View File

@ -200,7 +200,7 @@ function ninja:on_collide(e1, e2, dx, dy)
elseif (e2.type == "obake" or e2.type == "porc") and self.hit == 0 then
--lutro.audio.play(sfx_hit)
lutro.audio.play(sfx_hit)
screen_shake = 0.25
self.hit = 60
if dx > 0 then
@ -210,7 +210,7 @@ function ninja:on_collide(e1, e2, dx, dy)
end
self.y = self.y - 1
self.yspeed = -1
--self.hp = self.hp - 1
hp = hp - 1
end
end