- [NEW] taulells que es trenquen i cauen

This commit is contained in:
2026-02-25 20:17:19 +01:00
parent a7fb3d5c22
commit 5bf2a5391a
4 changed files with 52 additions and 1 deletions

View File

@@ -100,4 +100,10 @@ animations = {
{ frame={x=32,y=0,w=13,h=7}, wait=100 }, { frame={x=32,y=0,w=13,h=7}, wait=100 },
} }
}, },
["brick"] = {
cycle = {1},
frames = {
{ frame={x=48,y=0,w=8,h=8}, wait=100 },
}
},
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

After

Width:  |  Height:  |  Size: 724 B

View File

@@ -221,6 +221,20 @@ sprites = {
end end
end, end,
update_brick = function(spr)
if spr.timeout > 0 then
spr.timeout = spr.timeout - 1
if spr.timeout == 0 then
local tx, ty = spr.pos.x>>3, spr.pos.y>>3
map.tile(tx,ty,0)
end
else
spr.pos.y = spr.pos.y + 2
local tx, ty = (spr.pos.x+2)>>3, (spr.pos.y)>>3
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
end
end,
update_hero = function() update_hero = function()
--game.draw_light(sprites.hero.pos.x, sprites.hero.pos.y,100) --game.draw_light(sprites.hero.pos.x, sprites.hero.pos.y,100)
@@ -228,11 +242,14 @@ sprites = {
local anim = "hero_stand" local anim = "hero_stand"
local move_anim = "hero_walk" local move_anim = "hero_walk"
-- Si estem en cooldown desde l'ultim dispar, decrementem el contador
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
-- si està en l'animació de disparar, no podem fer res i eixim ja
if sprites.hero.shooting then if sprites.hero.shooting then
-- 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 if sprites.hero.current_frame==3 then
sprites.hero.shooting = false sprites.hero.shooting = false
if sprites.hero.flipped then sprites.hero.pos.x=sprites.hero.pos.x+8 end if sprites.hero.flipped then sprites.hero.pos.x=sprites.hero.pos.x+8 end
@@ -241,6 +258,7 @@ sprites = {
return return
end end
end end
-- SI ESTÀ BOTANT... -- SI ESTÀ BOTANT...
if sprites.hero.jumping > 0 then if sprites.hero.jumping > 0 then
anim = "hero_jump" anim = "hero_jump"
@@ -294,7 +312,9 @@ sprites = {
--draw.rect(tx1<<3, (ty+2)<<3,8,8,8) --draw.rect(tx1<<3, (ty+2)<<3,8,8,8)
--draw.rect(tx2<<3, (ty+2)<<3,8,8,28) --draw.rect(tx2<<3, (ty+2)<<3,8,8,28)
-- SI ESTÀ CAIGUENT... -- SI ESTÀ CAIGUENT...
if map.tile(tx1,ty+2) == 0 and map.tile(tx2,ty+2) == 0 then local tile_under_me1 = map.tile(tx1,ty+2)
local tile_under_me2 = map.tile(tx2,ty+2)
if tile_under_me1 == 0 and tile_under_me2 == 0 then
if ty+2>rooms.pos.y+11 then if ty+2>rooms.pos.y+11 then
game.change_room(0,1) game.change_room(0,1)
else else
@@ -302,6 +322,16 @@ sprites = {
end end
else else
-- SI NO ESTÀ CAIGUENT... -- SI NO ESTÀ CAIGUENT...
if tile_under_me1==84 then
map.tile(tx1,ty+2,68)
local broken_tile = templates.create("brick", {pos={x=tx1<<3, y=(ty+2)<<3}, flipped=sprites.hero.flipped})
table.insert(sprites.list, broken_tile)
end
if tile_under_me2==84 then
map.tile(tx2,ty+2,68)
local broken_tile = templates.create("brick", {pos={x=tx2<<3, y=(ty+2)<<3}, flipped=sprites.hero.flipped})
table.insert(sprites.list, broken_tile)
end
sprites.hero.pos.y = (ty<<3)-1 sprites.hero.pos.y = (ty<<3)-1
anim = "hero_stand" anim = "hero_stand"
-- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL... -- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL...

View File

@@ -52,6 +52,21 @@ templates = {
light_oy = 4, light_oy = 4,
ia = sprites.update_coin ia = sprites.update_coin
} }
elseif type == "brick" then
sprite = {
type = type,
pos = options.pos,--{ x=100, y=4*12*8+71 },
size = { w=8,h=8 },
bbo = { left=0, top=0, right=0, bottom=0 },
current_frame = 1,
current_wait = 1,
flipped = options.flipped,
surf = surf.load("misc.gif"),
animation = "brick",
state = templates.ALIVE,
timeout = 10,
ia = sprites.update_brick
}
else else
error("Template not recognized") error("Template not recognized")
end end