From 5bf2a5391a0ccb05f9c62373990ca0df5436a414 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Wed, 25 Feb 2026 20:17:19 +0100 Subject: [PATCH] - [NEW] taulells que es trenquen i cauen --- data/animations.lua | 6 ++++++ data/misc.gif | Bin 697 -> 724 bytes data/sprites.lua | 32 +++++++++++++++++++++++++++++++- data/templates.lua | 15 +++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/data/animations.lua b/data/animations.lua index 64e2c46..519ef14 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -100,4 +100,10 @@ animations = { { 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 }, + } + }, } \ No newline at end of file diff --git a/data/misc.gif b/data/misc.gif index fae2c665d8691eec1372f21c5375c06ab68d101a..c5ed9cf6778ce4f00598ca14941a8d9767f660d2 100644 GIT binary patch delta 558 zcmV+}0@3}s1=IzQkAI4vFbKBrwS4dYz@TtQ1O^;P$Lpw6F<+utw1gxjUjju|p;Z*W z;ILSHjF=?MaA1)&^X$}#9Y)wvuN^o$703TWlk2`#ml$9fb ze}RLHPi`xTib{-@q@|Nb8L5Pqshn+xhgMZrrnRb#?95%md^(m+uYRG-{5`P+}+{k=S9!t0T@!~@9-!G?CtFC@%Z2|^W56r z`2dHhlhN&8z=O_6kgHb$p+jNMfJHO-u%g9_7&B_z$g!ixk03*e97)n+u{n1`f^+;4pyfCAf0wVx8AkVBD}10t+^g^4DLl zf&&Mr+t+Vc#EI2Dn7q`-Tfm7YG;9pJFn@sO37`XLw#&JXh6Ru~C|ICj z@Ma^gW6!S5xV5bS8eU6KAX@_O-a>#2C$7M_X5YWV!X92+#t_pCrZbl?6?!G?0Txhi z-koaL@Zz_#_I@-Q4h54H1Q0+r+kyA-=dWjP1jpoPli^UGe``S#AbtFiG9OWWBtRoz w9|AUb9|D32lZ^r=AT-u!u<^TWy delta 531 zcmV+u0_^?N1-S)~kAJpwZQppV?|ctCK*uWpe2t1QW2{I-`kv6Jbc%9Bt`Xt!sueYj zu9c897IvxVv^q-6Ix^ZeeCS+NnPnn)&F}l$KyzDyUUgnWdSr@cevOV)L>ZETk%UK# zVJl=sL3@v%pgB!-Un-@ho-#3^tWT;lY$ZuFuy(Dtd;tf$ynnl%xWK_^x(67>$G^hL z%R9Qq&&kZv(e+PVS8B-qj0izq)M4O4e;Q>0i)#{ zFwm-W0EYojwQ~LXb?7;)tcWm8I-zY_6BTJ`W$M;#0I+D&&ShJ7Xw|>J)Y7dxAzxm8 zYunN-F<`*IWC0RSSR9~m(ZjAZELfm`gMtMb>>B>5nSZlq&=c@t{uDriW(l1YNC@2+ zVC&bhXBS@0n(1cPo+Zd==6eBf**{WSH#f}oa)m`h$oA1-zJBeNFq0}#dU;h0600t=FfCLt3;DHDxsNgn&3^wTC VgAhh2;R1vdlZ^r=1r&w=06U441HS+O diff --git a/data/sprites.lua b/data/sprites.lua index 012bf75..d6905e1 100644 --- a/data/sprites.lua +++ b/data/sprites.lua @@ -221,6 +221,20 @@ sprites = { 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() --game.draw_light(sprites.hero.pos.x, sprites.hero.pos.y,100) @@ -228,11 +242,14 @@ sprites = { local anim = "hero_stand" local move_anim = "hero_walk" + -- Si estem en cooldown desde l'ultim dispar, decrementem el contador if sprites.hero.cooldown > 0 then sprites.hero.cooldown = sprites.hero.cooldown - 1 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 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 @@ -241,6 +258,7 @@ sprites = { return end end + -- SI ESTÀ BOTANT... if sprites.hero.jumping > 0 then anim = "hero_jump" @@ -294,7 +312,9 @@ sprites = { --draw.rect(tx1<<3, (ty+2)<<3,8,8,8) --draw.rect(tx2<<3, (ty+2)<<3,8,8,28) -- 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 game.change_room(0,1) else @@ -302,6 +322,16 @@ sprites = { end else -- 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 anim = "hero_stand" -- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL... diff --git a/data/templates.lua b/data/templates.lua index 7d3ef44..ecada9b 100644 --- a/data/templates.lua +++ b/data/templates.lua @@ -52,6 +52,21 @@ templates = { light_oy = 4, 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 error("Template not recognized") end