- [NEW] guardem una safe_pos al entrar en cada habitació

- [FIX] Al morir, o tornar al editor, se reseteja l'heroi
- [FIX] Ja no canvia d'habitació al asomar el cabet per dalt al botar
- [NEW] Més habitacions (21%)
This commit is contained in:
2026-03-23 18:46:27 +01:00
parent 130c5d62e1
commit a98a46a3d2
7 changed files with 27 additions and 18 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -95,11 +95,11 @@ function ia.update_hero()
--draw.rect(tx1<<3,ty<<3,8,8,8)
--draw.rect(tx2<<3,ty<<3,8,8,28)
if map.tile(tx1,ty) == 0 and map.tile(tx2,ty) == 0 then
if ty+1<rooms.pos.y then
game.change_room(0,-1)
else
--if ty+1<rooms.pos.y then
-- game.change_room(0,-1)
--else
if sprites.hero.jumping > 1 then sprites.hero.pos.y = sprites.hero.pos.y - 1 end
end
--end
else
sprites.hero.jumping = 0
sprites.hero.jump_throttle = 10
@@ -165,6 +165,7 @@ function ia.update_hero()
end
sprites.hero.pos.y = (ty<<3)-1
anim = "hero_stand"
sprites.save_safe_pos()
-- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL...
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
@@ -261,3 +262,15 @@ function ia.hero_give_key(color)
tweening.add(1,0,0.25,easing.linear,function(value,n,finished)palfade.fade_white(value)end)
return true
end
function ia.hero_reset()
sprites.hero.state = templates.ALIVE
sprites.hero.lives = 4
sprites.hero.surf = surf.load("gfx/morcus.gif")
sprites.hero.animation = "hero_stand"
sprites.hero.current_frame = 1
sprites.hero.current_wait = 1
sprites.hero.flipped = false
sprites.hero.light = 100
sprites.hero.pos = {x=sprites.last_safe_pos.x,y=sprites.last_safe_pos.y}
end

View File

@@ -5,6 +5,9 @@ sprites = {
hero = nil,
list = {},
pause_ia = false,
--initial_pos = { x=28, y=4*13*8+79 }
last_safe_room = 0 + 4 * 8,
last_safe_pos = { x=28, y=4*13*8+79 }
}
function sprites.remove(sprite)
@@ -17,15 +20,12 @@ function sprites.remove(sprite)
end
end
function sprites.remove_out_of_room()
--print("Current room: "..rooms.current())
--for i,v in ipairs(sprites.list) do
-- if v.room ~= rooms.current() then
-- table.remove(sprites.list, i)
-- local room = v.room or 0
-- print("Sprite at room "..room.." removed: "..v.type)
-- end
--end
function sprites.save_safe_pos()
local room = (rooms.pos.x//20) + (rooms.pos.y//12) * 8
if room ~= sprites.last_safe_room then
sprites.last_safe_room = room
sprites.last_safe_pos = {x=sprites.hero.pos.x, y=sprites.hero.pos.y}
end
end
function sprites.add_from_room(rx,ry)

View File

@@ -130,19 +130,15 @@ editor = {
menu.toggle()
elseif key.press(key.RIGHT) and rooms.pos.x < 20*7 then
rooms.pos.x = rooms.pos.x + 20
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.LEFT) and rooms.pos.x > 0 then
rooms.pos.x = rooms.pos.x - 20
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.DOWN) and rooms.pos.y < 13*7 then
rooms.pos.y = rooms.pos.y + 13
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.UP) and rooms.pos.y > 0 then
rooms.pos.y = rooms.pos.y - 13
sprites.remove_out_of_room()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
elseif key.press(key.TAB) or key.press(key.ESCAPE) then
if editor.layer==LAYER_BACKGROUND or editor.layer==LAYER_FOREGROUND then

View File

@@ -65,6 +65,7 @@ game = {
if key.press(key.ESCAPE) or key.press(key.F9) then
rooms.reload()
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
ia.hero_reset()
editor.enable()
elseif key.press(key.GRAVE) then
console.enable()
@@ -106,7 +107,6 @@ game = {
game.chg_step = game.chg_step - 1
if game.chg_step == 0 then
sprites.remove_out_of_room()
sprites.pause_ia = false
app.pop()
--sys.beat(2)