- [NEW] Quan li peguen, Morcus pega un botet cap enrere

- [NEW] Quan peguen a l'heroi, la momia i la rata peguen la volta
This commit is contained in:
2026-03-23 12:17:05 +01:00
parent abb3e5e048
commit 7090a6134f
3 changed files with 34 additions and 1 deletions

View File

@@ -49,6 +49,33 @@ function ia.update_hero()
end
end
-- Si li han pegat...
if sprites.hero.has_been_hit then
if sprites.hero.flipped then
local tx, ty = (sprites.hero.pos.x+3)>>3, (sprites.hero.pos.y+16)>>3
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
if tx<rooms.pos.x then
game.change_room(-1,0)
else
sprites.hero.pos.x = sprites.hero.pos.x + 1
end
end
else
local tx, ty = (sprites.hero.pos.x+12)>>3, (sprites.hero.pos.y+16)>>3
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
if tx>rooms.pos.x+19 then
game.change_room(1,0)
else
sprites.hero.pos.x = sprites.hero.pos.x - 1
end
end
end
sprites.hero.has_been_hit = sprites.hero.has_been_hit - 1
if sprites.hero.has_been_hit == 0 then
sprites.hero.has_been_hit = nil;
end
end
-- si està en l'animació de disparar, no podem fer res i eixim ja
if sprites.hero.shooting then
-- A no ser que siga l'ultim frame, en tal cas tornem a estar de peu i au
@@ -165,7 +192,7 @@ function ia.update_hero()
end
end
-- ESTIGA COM ESTIGA, SI POLSA ESQUERRA O DRETA...
if not sprites.hero.shooting then
if not sprites.hero.shooting and not sprites.hero.has_been_hit then
if key.down(key.LEFT) or pad.down(pad.LEFT) then
sprites.hero.flipped = true
anim = move_anim
@@ -221,6 +248,10 @@ function ia.hero_hit(live)
elseif sprites.hero.lives < 4 then
sprites.hero.state = templates.DYING
sprites.hero.cooldown = 60
sprites.hero.shooting = false
sprites.set_animation(sprites.hero, "hero_stand")
sprites.hero.jumping = 8
sprites.hero.has_been_hit = 16
end
end

View File

@@ -8,6 +8,7 @@ function ia.update_mummy(spr)
-- Si toca al heroi...
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
sprites.hero.hit()
spr.flipped = not spr.flipped
end
end

View File

@@ -7,6 +7,7 @@ function ia.update_rata(spr)
-- Si toca al heroi...
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
sprites.hero.hit()
spr.flipped = not spr.flipped
end
end