- [FIX] Si hi ha que ficar un offset en algun frame de animació, es fà des de la propia animació, no canviant la posició del personatge

- [NEW] rooms.reload()
- [FIX] Al tornar al editor, se recarrega tot de nou
- [NEW] Si se juga des de un mini de debug comença en l'editor. Si se juga des del mini normal comença en el joc.
This commit is contained in:
2026-03-04 11:08:16 +01:00
parent 8e5599506e
commit f6b99d7924
7 changed files with 25 additions and 42 deletions

View File

@@ -258,7 +258,6 @@ sprites = {
-- A no ser que siga l'ultim frame, en tal cas tornem a estar de peu i au
if sprites.hero.current_frame==3 then
sprites.hero.shooting = false
if sprites.hero.flipped then sprites.hero.pos.x=sprites.hero.pos.x+8 end
sprites.set_animation(sprites.hero, "hero_stand")
else
return
@@ -360,10 +359,8 @@ sprites = {
elseif (sprites.hero.cooldown==0) and (key.down(key.Z) or pad.down(pad.B)) then
sprites.hero.shooting = true
sprites.hero.cooldown = 20
local x = sprites.hero.flipped and sprites.hero.pos.x+8 or sprites.hero.pos.x-8
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)
if sprites.hero.flipped then sprites.hero.pos.x=sprites.hero.pos.x-8 end
anim = "hero_shoot"
end
end
@@ -422,12 +419,21 @@ sprites = {
draw_sprite = function(sprite)
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
local frame = animations[sprite.animation].frames[cycle]
local ox, oy = 0, 0
if frame.offset then
if sprite.flipped then
if frame.offset.flipped then ox,oy = frame.offset.flipped.x,frame.offset.flipped.y end
else
if frame.offset.normal then ox,oy = frame.offset.normal.x,frame.offset.normal.y end
end
end
if not frame then
print(sprite.current_frame)
end
local reversed = frame.reversed or false
surf.source(sprite.surf)
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, frame.frame.w, frame.frame.h, (not reversed) ~= (not sprite.flipped))
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x+ox, sprite.pos.y+oy, frame.frame.w, frame.frame.h, (not reversed) ~= (not sprite.flipped))
if cheats.showaabb then
local x,y,w,h = util.aabb(sprite)
draw.rect(x,y,w,h,8)