From 12673f1dc4c52d79f8f019d20eda31fd6297258b Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Tue, 24 Feb 2026 13:23:16 +0100 Subject: [PATCH] =?UTF-8?q?-=20[NEW]=20Animaci=C3=B3=20de=20moneda=20agafa?= =?UTF-8?q?da=20-=20[NEW]=20Agafar=20monedes=20augmenta=20el=20marcador=20?= =?UTF-8?q?-=20[NEW]=20Marcador=20b=C3=A0sic=20visible=20-=20[NEW]=20Al=20?= =?UTF-8?q?cambiar=20d'habitaci=C3=B3=20es=20mant=C3=A9=20el=20efecte=20d'?= =?UTF-8?q?iluminaci=C3=B3.=20A=20m=C3=A9s,=20va=20un=20poc=20m=C3=A9s=20l?= =?UTF-8?q?ento=20-=20[NEW]=20Al=20agafar=20moneda,=20no=20torna=20al=20ei?= =?UTF-8?q?xir=20i=20entrar.=20Al=20tornar=20al=20editor=20se=20recupera.?= =?UTF-8?q?=20-=20[NEW]=20Gesti=C3=B3=20de=20l'iluminaci=C3=B3=20fora=20de?= =?UTF-8?q?ls=20update=20i=20dins=20dels=20draw=20-=20[NEW]=20Afegides=20m?= =?UTF-8?q?=C3=A9s=20habitacions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/animations.lua | 6 ++ data/game.lua | 133 ++++++++++++++++++++++---------------- data/misc.gif | Bin 671 -> 697 bytes data/rooms.lua | 19 +++++- data/rooms_foreground.gif | Bin 1797 -> 2020 bytes data/rooms_items.gif | Bin 1034 -> 1038 bytes data/score.lua | 3 +- data/sprites.lua | 55 +++++++++++----- data/templates.lua | 4 ++ 9 files changed, 143 insertions(+), 77 deletions(-) diff --git a/data/animations.lua b/data/animations.lua index 68da322..64e2c46 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -94,4 +94,10 @@ animations = { { frame={x=24,y=0,w=8,h=8}, wait=2 } } }, + ["coin_picked"] = { + cycle = {1}, + frames = { + { frame={x=32,y=0,w=13,h=7}, wait=100 }, + } + }, } \ No newline at end of file diff --git a/data/game.lua b/data/game.lua index 99def56..f5a2f65 100644 --- a/data/game.lua +++ b/data/game.lua @@ -23,35 +23,100 @@ game = { update = function() game.water_counter = game.water_counter + 0.05 - local counter = game.water_counter view.origin(0,0) - surf.target(game.back_buf) + surf.target(0) view.clip() score.draw() + surf.target(game.back_buf) -- Pintar el mapa i sprites rooms.draw() sprites.update() - --sprites.update_hero() + game.apply_water() + game.apply_light() + + if key.press(key.ESCAPE) or key.press(key.F9) then + rooms.retrieve_original_items() + editor.enable() + end + end, + + change_room = function(x,y) + game.chg_adv.x = x*0.25 + game.chg_adv.y = y*0.25 + game.chg_step = 8*4 + sprites.pause_ia = true + -- [TODO] Crear els sprites per als items de l'habitació a la que entrem + sprites.add_from_room(rooms.pos.x+x*20, rooms.pos.y+y*12) + app.push(game.update_change_room) + --sys.beat(10) + end, + + update_change_room = function() + --if not sys.beat() then return end + view.origin(0,0) + surf.target(0) + view.clip() + + score.draw() + surf.target(game.back_buf) + --view.clip() + + -- Pintar el mapa i sprites + rooms.pos.x = rooms.pos.x + (game.chg_adv.x*2.5) + rooms.pos.y = rooms.pos.y + (game.chg_adv.y*1.5) + sprites.hero.pos.x = sprites.hero.pos.x + game.chg_adv.x + sprites.hero.pos.y = sprites.hero.pos.y + game.chg_adv.y + + rooms.draw() + sprites.update() + game.apply_water() + game.apply_light() + + 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) + end + end, + + draw_light = function(x,y,size) + surf.target(game.circ_buf) + local s = size+(game.light_strobe_value/2) + draw.mode(draw.OR) + draw.circf(x,y,s,1) + draw.circf(x,y,2*(s/3),2) + draw.mode(draw.NORMAL) + surf.target(game.back_buf) + end, + + apply_water = function() view.origin(0,0) if rooms.pos.y == 84 then surf.target(game.back_buf) surf.source(game.back_buf) for x=0,159 do - local water_level = math.sin(counter)*2 + local water_level = math.sin(game.water_counter)*2 for y=96+water_level,103 do local pixel = surf.pixel(x,y) surf.pixel(x,y,game.water_pal[pixel+1]) end end end + end, + + apply_light = function() + game.light_strobe_value = game.light_strobe_value + game.light_strobe_dir + if math.abs(game.light_strobe_value)==2 then + game.light_strobe_dir = -game.light_strobe_dir + end surf.target(0) - --surf.source(game.back_buf) - --draw.surf(0,0,160,104,0,0,160,104) for y=0,103 do for x=0,159 do surf.source(game.back_buf) @@ -60,60 +125,14 @@ game = { local light = surf.pixel(x,y) if light==0 then surf.pixel(x,y,1) - elseif light==1 then - surf.pixel(x,y,game.fade_pal[pixel+1]) - else + elseif (light&2)==2 then surf.pixel(x,y,pixel) + else + surf.pixel(x,y,game.fade_pal[pixel+1]) end end end - - if key.press(key.ESCAPE) or key.press(key.F9) then - editor.enable() - end - end, - - change_room = function(x,y) - game.chg_adv.x = x - game.chg_adv.y = y - game.chg_step = 8 - sprites.pause_ia = true - -- [TODO] Crear els sprites per als items de l'habitació a la que entrem - sprites.add_from_room(rooms.pos.x+x*20, rooms.pos.y+y*12) - app.push(game.update_change_room) - end, - - update_change_room = function() - view.origin(0,0) - surf.target(0) - view.clip() - - score.draw() - - -- Pintar el mapa i sprites - rooms.pos.x = rooms.pos.x + game.chg_adv.x*2.5 - rooms.pos.y = rooms.pos.y + game.chg_adv.y*1.5 - sprites.hero.pos.x = sprites.hero.pos.x + game.chg_adv.x - sprites.hero.pos.y = sprites.hero.pos.y + game.chg_adv.y - rooms.draw() - sprites.update() - game.chg_step = game.chg_step - 1 - if game.chg_step == 0 then - sprites.remove_out_of_room() - sprites.pause_ia = false - app.pop() - end - end, - - draw_light = function(x,y,size) - surf.target(game.circ_buf) - local s = size+game.light_strobe_value - draw.circf(x,y,s,1) - draw.circf(x,y,2*(s/3),2) - game.light_strobe_value = game.light_strobe_value + game.light_strobe_dir - if math.abs(game.light_strobe_value)==1 then - game.light_strobe_dir = -game.light_strobe_dir - end - --surf.target(game.circ_buf) end + + } \ No newline at end of file diff --git a/data/misc.gif b/data/misc.gif index 9dab1d4b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BA4*ZGD%RVd2=|9O1oDP? V0mI+l77{C*O)o2AgHAvI06ThZsh7y|+ClNke_QnBO5kRwZ;Tv)L|%akcL&dj;9=boDdhW<>tbi>i6 zBce`y5Hn%dtYdpzExWeu+XVw9q>a0`Z@sX86V#oMIAz`fg9~5Iyt(t|(4%7w2mm{v C=`Mu; diff --git a/data/score.lua b/data/score.lua index ba4a2d9..c4bd779 100644 --- a/data/score.lua +++ b/data/score.lua @@ -1,6 +1,7 @@ score = { - + points = 0, draw = function() draw.rectf(0,0,160,8,1) + draw.text(string.format("%03d", score.points),0,0,28) end } diff --git a/data/sprites.lua b/data/sprites.lua index f6dd430..62fe9bc 100644 --- a/data/sprites.lua +++ b/data/sprites.lua @@ -58,6 +58,9 @@ sprites = { animation = "hero_stand", ia = sprites.update_hero, jumping = 0, + light = 100, + light_ox = 0, + light_oy = 0, stairs = false } --table.insert(sprites.list, templates.create("mummy", {pos={x=100, y=4*12*8+71},flipped=true})) @@ -95,9 +98,6 @@ sprites = { update = function() if not sys.beat() then return end - surf.target(game.circ_buf) - surf.cls() - sprites.update_sprite(sprites.hero) for i,v in ipairs(sprites.list) do sprites.update_sprite(v) @@ -191,23 +191,37 @@ sprites = { end, update_coin = function(spr) - local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3 - - local x1,y1,w1,h1 = util.aabb(spr) - for i,v in ipairs(sprites.list) do - if v.enemy and v.state ~= templates.DEAD then - local x2,y2,w2,h2 = util.aabb(v) - if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then - if v.state == templates.ALIVE then v.state = templates.DYING end - sprites.remove(spr) - return - end + if spr.state == templates.ALIVE then + local x1,y1,w1,h1 = util.aabb(spr) + --for i,v in ipairs(sprites.list) do + --if v.type == "hero" then + local x2,y2,w2,h2 = util.aabb(sprites.hero) + if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then + local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3 + map.surf(rooms.surf_items) + map.tile(tx,ty,0) + + spr.state = templates.DYING + sprites.set_animation(spr, "coin_picked") + spr.pos.y=spr.pos.y-16 + spr.pos.x=spr.pos.x-4 + spr.timer = 0 + score.points = score.points + 10 + return + end + --end + --end + elseif spr.state == templates.DYING then + spr.pos.y = spr.pos.y - 0.5 + spr.timer = spr.timer + 1 + if spr.timer == 32 then + sprites.remove(spr) end end end, 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) -- Update hero local anim = "hero_stand" @@ -342,6 +356,12 @@ sprites = { end, draw = function(ignore_selected) + if app.update ~= editor.update then + surf.target(game.circ_buf) + surf.cls() + surf.target(game.back_buf) + end + editor.item_hovered = nil local mx,my = mouse.pos() if editor.item_selected or editor.layer~=LAYER_ITEMS then ignore_selected = true end @@ -365,8 +385,11 @@ sprites = { 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)) - local x,y,w,h = util.aabb(sprite) + --local x,y,w,h = util.aabb(sprite) --draw.rect(x,y,w,h,8) + if (app.update ~= editor.update) and (sprite.light) then + game.draw_light(sprite.pos.x+sprite.light_ox, sprite.pos.y+sprite.light_oy,sprite.light) + end end, draw_sprite_selected = function(sprite) diff --git a/data/templates.lua b/data/templates.lua index 031b283..7d3ef44 100644 --- a/data/templates.lua +++ b/data/templates.lua @@ -46,6 +46,10 @@ templates = { flipped = options.flipped, surf = surf.load("misc.gif"), animation = "coin", + state = templates.ALIVE, + light = 15, + light_ox = 4, + light_oy = 4, ia = sprites.update_coin } else