- [FIX] Retocs en habitacions

- [FIX] Quan mor, reapareix en l'habitació que toca
- [FIX] Després de morir, al agafar una clau es tornava tot roig infern (que por)
- [FIX] Si no hi havia objectes amb llum en l'habitació on mories, mai resucitaves
- [FIX] Al resucitar, totes les llums s'encenen desde cero, no nomes la teua
- [FIX] Quan t'havien pegat, no podies disparar durant el cooldown
- [FIX] Menos posibilitats de que la "safe position" estiga en un lloc mortal
This commit is contained in:
2026-03-27 20:37:06 +01:00
parent 49396331a7
commit 51f267284e
6 changed files with 56 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -28,6 +28,11 @@ function ia.update_hero()
local move_anim = "hero_walk" local move_anim = "hero_walk"
-- Si estem en cooldown desde l'ultim dispar, decrementem el contador -- Si estem en cooldown desde l'ultim dispar, decrementem el contador
-- Si estem en cooldown desde l'ultim dispar, decrementem el contador
if sprites.hero.gun_cooldown > 0 then
sprites.hero.gun_cooldown = sprites.hero.gun_cooldown - 1
end
if sprites.hero.cooldown > 0 then if sprites.hero.cooldown > 0 then
sprites.hero.cooldown = sprites.hero.cooldown - 1 sprites.hero.cooldown = sprites.hero.cooldown - 1
end end
@@ -167,7 +172,7 @@ function ia.update_hero()
sprites.hero.pos.y = (ty<<3)-1 sprites.hero.pos.y = (ty<<3)-1
end end
anim = "hero_stand" anim = "hero_stand"
sprites.save_safe_pos() if sprites.hero.state == templates.ALIVE then sprites.save_safe_pos() end
-- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL... -- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL...
if (map.tile(txm,ty+2) < 16 and map.tile(txm,ty+2) > 0) then if (map.tile(txm,ty+2) < 16 and map.tile(txm,ty+2) > 0) then
if key.down(key.DOWN) or pad.down(pad.DOWN) then if key.down(key.DOWN) or pad.down(pad.DOWN) then
@@ -184,9 +189,9 @@ function ia.update_hero()
sprites.hero.jumping = 17 sprites.hero.jumping = 17
-- SI POLSA DISPAR... -- SI POLSA DISPAR...
elseif (sprites.hero.cooldown==0) and (key.down(key.Z) or pad.down(pad.B)) then elseif (sprites.hero.gun_cooldown==0) and (key.down(key.Z) or pad.down(pad.B)) then
sprites.hero.shooting = true sprites.hero.shooting = true
sprites.hero.cooldown = 20 sprites.hero.gun_cooldown = 20
local bullet = templates.create("bullet", {pos={x=sprites.hero.pos.x, y=sprites.hero.pos.y+7}, flipped=sprites.hero.flipped}) local bullet = templates.create("bullet", {pos={x=sprites.hero.pos.x, y=sprites.hero.pos.y+7}, flipped=sprites.hero.flipped})
table.insert(sprites.list, bullet) table.insert(sprites.list, bullet)
anim = "hero_shoot" anim = "hero_shoot"
@@ -244,6 +249,7 @@ function ia.hero_hit(live)
if sprites.hero.lives == 0 then if sprites.hero.lives == 0 then
sprites.hero.state = templates.DEAD sprites.hero.state = templates.DEAD
sprites.hero.invisible = nil
sprites.hero.surf = surf.load("gfx/mummy.gif") sprites.hero.surf = surf.load("gfx/mummy.gif")
sprites.set_animation(sprites.hero, "mummy_dying") sprites.set_animation(sprites.hero, "mummy_dying")
sprites.hero.jumping = 0 sprites.hero.jumping = 0
@@ -276,4 +282,6 @@ function ia.hero_reset()
sprites.hero.flipped = false sprites.hero.flipped = false
sprites.hero.light = 100 sprites.hero.light = 100
sprites.hero.pos = {x=sprites.last_safe_pos.x,y=sprites.last_safe_pos.y} sprites.hero.pos = {x=sprites.last_safe_pos.x,y=sprites.last_safe_pos.y}
rooms.go_to_room(sprites.last_safe_room)
palfade.init()
end end

View File

@@ -143,3 +143,8 @@ function rooms.toggle_visibility(layer)
rooms.visibility = rooms.visibility | layer rooms.visibility = rooms.visibility | layer
end end
end end
function rooms.go_to_room(room)
rooms.pos.x = (room % 8) * 20
rooms.pos.y = (room // 8) * 13
end

View File

@@ -21,11 +21,14 @@ function sprites.remove(sprite)
end end
function sprites.save_safe_pos() function sprites.save_safe_pos()
local room = (rooms.pos.x//20) + (rooms.pos.y//12) * 8 local room = rooms.current()
if room ~= sprites.last_safe_room then --local hero_room = (sprites.hero.pos.x//160)*20 + ((sprites.hero.pos.y//104)*12) * 8
--if room ~= hero_room then return end
if room == sprites.last_safe_room then return end
sprites.last_safe_room = room sprites.last_safe_room = room
sprites.last_safe_pos = {x=sprites.hero.pos.x, y=sprites.hero.pos.y} sprites.last_safe_pos = {x=sprites.hero.pos.x, y=sprites.hero.pos.y}
end --print("safepos: " .. sprites.last_safe_pos.x .. ", " .. sprites.last_safe_pos.y)
end end
function sprites.add_from_room(rx,ry) function sprites.add_from_room(rx,ry)
@@ -63,6 +66,7 @@ function sprites.init()
light_ox = 8, light_ox = 8,
light_oy = 8, light_oy = 8,
cooldown = 0, cooldown = 0,
gun_cooldown = 0,
jump_throttle = 0, jump_throttle = 0,
lives = 4, lives = 4,
keys = {}, keys = {},
@@ -124,9 +128,9 @@ function sprites.lights_out()
spr.light = value spr.light = value
if finished then if finished then
spr.light = nil spr.light = nil
if sprites.hero.state == templates.DEAD then --if sprites.hero.state == templates.DEAD then
game.restart() -- game.restart()
end --end
end end
end end
) )
@@ -137,11 +141,32 @@ function sprites.lights_out()
sprites.hero.light = value sprites.hero.light = value
if finished then if finished then
sprites.hero.light = nil sprites.hero.light = nil
game.restart()
end end
end end
) )
end end
function sprites.lights_in()
for i,spr in ipairs(sprites.list) do
if spr.light then
tweening.add(0,spr.light,0.5,easing.linear,
function(value,n,finished)
spr.light = value
end
)
end
end
-- tweening.add(sprites.hero.light,0,0.5,easing.linear,
-- function(value,n,finished)
-- sprites.hero.light = value
-- if finished then
-- sprites.hero.light = nil
-- end
-- end
-- )
end
function sprites.draw(ignore_selected) function sprites.draw(ignore_selected)
if app.update ~= editor.update then if app.update ~= editor.update then
surf.target(game.circ_buf) surf.target(game.circ_buf)

View File

@@ -37,12 +37,13 @@ game = {
end, end,
restart = function() restart = function()
rooms.reload() --rooms.reload()
ia.hero_reset()
sprites.add_from_room(rooms.pos.x, rooms.pos.y) sprites.add_from_room(rooms.pos.x, rooms.pos.y)
pal.set(palfade.original) pal.set(palfade.original)
ia.hero_reset()
sprites.hero.light = 0 sprites.hero.light = 0
tweening.add(0,100,1,easing.linear,function(value,n,finished)sprites.hero.light = value end) tweening.add(0,100,1,easing.linear,function(value,n,finished)sprites.hero.light = value end)
sprites.lights_in()
score.init(true) score.init(true)
end, end,
@@ -72,6 +73,10 @@ game = {
score.draw() score.draw()
view.origin(0,0)
draw.text("safe: "..sprites.last_safe_room,1,96,28)
--draw.text(sprites.hero.pos.x ..","..sprites.hero.pos.y,14,89,28)
if key.press(key.ESCAPE) or key.press(key.F9) then if key.press(key.ESCAPE) or key.press(key.F9) then
rooms.reload() rooms.reload()
sprites.add_from_room(rooms.pos.x, rooms.pos.y) sprites.add_from_room(rooms.pos.x, rooms.pos.y)