From 6fff1996f1e1ba7df997aa4e8247287dc500123a Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Sat, 21 Jun 2025 17:28:59 +0200 Subject: [PATCH] - [NEW] Ja camina, bota, cau, puja i baixa escales i cordes --- data/animations.lua | 21 +++++++++- data/game.lua | 2 +- data/rooms.lua | 3 +- data/rooms_background.bin | Bin 227 -> 227 bytes data/rooms_foreground.bin | Bin 274 -> 300 bytes data/sprites.gif | Bin 1199 -> 1264 bytes data/sprites.lua | 84 ++++++++++++++++++++++++++++++++++---- data/tiles.gif | Bin 952 -> 960 bytes 8 files changed, 100 insertions(+), 10 deletions(-) diff --git a/data/animations.lua b/data/animations.lua index 69fc144..04f94b8 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -6,6 +6,12 @@ animations = { { frame={x=0,y=0,w=16,h=17}, wait=2 }, } }, + ["hero_jump"] = { + cycle = {1}, + frames = { + { frame={x=32,y=0,w=16,h=17}, wait=2 }, + } + }, ["hero_walk"] = { cycle = {1,2,1,3}, frames = { @@ -13,5 +19,18 @@ animations = { { frame={x=16,y=0,w=16,h=17}, wait=2 }, { frame={x=32,y=0,w=16,h=17}, wait=2 } } - } + }, + ["hero_stairs_idle"] = { + cycle = {1}, + frames = { + { frame={x=48,y=0,w=16,h=17}, wait=2 } + } + }, + ["hero_stairs"] = { + cycle = {1,2}, + frames = { + { frame={x=48,y=0,w=16,h=17}, wait=2 }, + { frame={x=48,y=0,w=16,h=17}, wait=2, reversed=true } + } + }, } \ No newline at end of file diff --git a/data/game.lua b/data/game.lua index 18da5ce..6b1c652 100644 --- a/data/game.lua +++ b/data/game.lua @@ -3,7 +3,7 @@ game = { enable = function() app.update = game.update sys.beat(2) - shader.enable(); + --shader.enable(); end, update = function() diff --git a/data/rooms.lua b/data/rooms.lua index b680cdf..38f6f11 100644 --- a/data/rooms.lua +++ b/data/rooms.lua @@ -35,10 +35,11 @@ rooms = { draw.surf(0,0,160,96,0,0) sprites.init() + --map.surf(rooms.surf_background) --for y=0,12*8 do -- for x=0,20*8 do - -- map.tile(x,y,1) + -- map.tile(x,y,38) -- end --end --map.surf(rooms.surf_foreground) diff --git a/data/rooms_background.bin b/data/rooms_background.bin index 86d92717f120fe361e18ba088524c9521b9fda5b..a3fb1cacaabc4305febc02399ef97af29b3a7a0d 100644 GIT binary patch delta 11 ScmaFN_?U5m6r=A%=@S4NPXsjp delta 11 ScmaFN_?U5m6eIIQ=@S4MCj;vM diff --git a/data/rooms_foreground.bin b/data/rooms_foreground.bin index 9b4868c59610ec563e0c8269a98157a7868d19f6..9aca9f879e40176d15ea8f7595bc2bbcdf5b3609 100644 GIT binary patch delta 112 zcmV-$0FVEY0;~d%7yLZQuABKoI6bs1__H9KLuy3^2!RI-f;eF9{5$c2lKQ zg{5u*C23Oog__T3aCYn^Vb|5`dmLB)ko0nT&!@emfOR`;Y)f{8ZDDJ7M178rLJpD) z6C4Z-99w^ZJVcwEjf#Mckfo*p4h*T40~`ZisFRhKnOu^qmVcPA4nw@Azon>`loQ3p znyI+0uePd`uCAIBx6}?3dcfIF!k5Oz$iv>pSE=3NRsqx1lGobqXaV69-MjMM;O6&N zs@2!n?*MBA(6C^E0uBlm=!s{Jo(_2quMjLqG2Op_7++{0DB++22^z`_WFSBTLWMd8 z|4ckcFr-9|5`SWXWNKUq{OHq- zfJ;F&C?FNDs6mq-lgd#*w(L`=85s&7`+#g!Fai!75U}<^+W-PI;jP%tOr^P(O6 zLayBdc45&yZ1@3P#f=}&*ejT@Ww?PeE6!U&u4FEc1Am{rOuDq`)2LIcUd_6->({Vj z%brcU_Us{~Z0o*qfYX7$Mqc3FeRGH0I~YXv4)j~cazM?AV;rO;i%1B^t0&ii{Q&aO z()$F^E?4e#jTXykl9N~z?MX;?S~gmc(c zpk5JnvLluW0=Z>_X7a!ogxO6=rXx+3CnO2xDSzT7PUg+|=AL}^>F1w-1}f;FgcfS3 zc)>L>+@WSzsD%@b8p5ceb3BQID0u`ip`p|v@~A-lW%|ITgnkmpnA~wPN&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R(jH;yyhC*9 zufPBgv4$RF9xNsf1(VkY8PjSv#+&LUIVUB 0 then + anim = "hero_jump" + local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y)>>3 + if map.tile(tx1,ty) == 0 and map.tile(tx2,ty) == 0 then + sprites.hero.pos.y = sprites.hero.pos.y - 2 + end + sprites.hero.jumping = sprites.hero.jumping - 2 + else + local txm, ty = (sprites.hero.pos.x+8)>>3, (sprites.hero.pos.y+8)>>3 + if (map.tile(txm,ty) > 0 and map.tile(txm,ty) < 16) or (map.tile(txm,ty+1) > 0 and map.tile(txm,ty+1) < 16) then + anim = "hero_stairs_idle" + move_anim = "hero_stairs" + if key.down(key.UP) then + anim = move_anim + local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y)>>3 + if map.tile(tx1,ty) < 16 or map.tile(tx2,ty) < 16 then + sprites.hero.pos.y = sprites.hero.pos.y - 1 + end + elseif key.down(key.DOWN) then + anim = move_anim + local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3 + if map.tile(tx1,ty+2) < 16 or map.tile(tx2,ty+2) < 16 then + sprites.hero.pos.y = sprites.hero.pos.y + 1 + end + end + else + local tx1, txm, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+8)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3 + draw.rect(tx1<<3, (ty+2)<<3,8,8,8) + draw.rect(tx2<<3, (ty+2)<<3,8,8,28) + if map.tile(tx1,ty+2) == 0 and map.tile(tx2,ty+2) == 0 then + sprites.hero.pos.y = sprites.hero.pos.y + 2 + else + sprites.hero.pos.y = (ty<<3)-1 + anim = "hero_stand" + if (map.tile(txm,ty+2) < 16 and map.tile(txm,ty+2) > 0) then + if key.down(key.DOWN) then + anim = "hero_stairs" + --local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3 + --if map.tile(tx1,ty+2) < 16 or map.tile(tx2,ty+2) < 16 then + sprites.hero.pos.x = (txm << 3)-4 + sprites.hero.pos.y = sprites.hero.pos.y + 1 + --end + end + end + if key.down(key.SPACE) then + sprites.hero.jumping = 16 + end + end + end + end if key.down(key.LEFT) then sprites.hero.flipped = true - sprites.set_animation(sprites.hero, "hero_walk") - sprites.hero.pos.x = sprites.hero.pos.x - 1 + anim = move_anim + local tx, ty = (sprites.hero.pos.x+3)>>3, (sprites.hero.pos.y+16)>>3 + if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then + sprites.hero.pos.x = sprites.hero.pos.x - 1 + end elseif key.down(key.RIGHT) then sprites.hero.flipped = false - sprites.set_animation(sprites.hero, "hero_walk") - sprites.hero.pos.x = sprites.hero.pos.x + 1 - else - sprites.set_animation(sprites.hero, "hero_stand") + anim = move_anim + local tx, ty = (sprites.hero.pos.x+13)>>3, (sprites.hero.pos.y+16)>>3 + if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then + sprites.hero.pos.x = sprites.hero.pos.x + 1 + end end + + sprites.set_animation(sprites.hero, anim) end, update_sprite = function(sprite) @@ -64,6 +133,7 @@ sprites = { draw_sprite = function(sprite) local cycle = animations[sprite.animation].cycle[sprite.current_frame] local frame = animations[sprite.animation].frames[cycle] - draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h, sprite.flipped) + local reversed = frame.reversed or false + draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h, (not reversed) ~= (not sprite.flipped)) end } \ No newline at end of file diff --git a/data/tiles.gif b/data/tiles.gif index 56f1a4a3cb404fe024c30de6e8e8d1f53b276d17..f4153c4678ce995c2a3e2513b82bdd5d992ecefd 100644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