From 45ea1b33bf385c7bab299f8b2390106b2a0c83ba Mon Sep 17 00:00:00 2001 From: JailGamer Date: Sun, 10 May 2026 14:08:11 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=20Canviat=20el=20nom=20de=20flow=20a=20st?= =?UTF-8?q?ates=20que=20es=20mes=20precis=20[FIX]=20Ajustada=20posici?= =?UTF-8?q?=C3=B3=20del=20peu=20en=20habitaci=C3=B3=2027=20[FIX]=20Modific?= =?UTF-8?q?at=20trigger=5Fevent=20per=20a=20que=20es=20disparen=20en=20una?= =?UTF-8?q?=20habitaci=C3=B3=20concreta=20i=20tamb=C3=A9=20segons=20distan?= =?UTF-8?q?cia=20sense=20haver=20de=20colisionar=20[FIX]=20Ending=20stage?= =?UTF-8?q?=201=20[FIX]=20ELiminades=20llunes=20duplicades=20[NEW]=20Diale?= =?UTF-8?q?g=20per=20a=20l'abad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/batvio.lua | 7 ++++-- data/bol.lua | 1 + data/game.lua | 4 ++-- data/intro.lua | 8 +++---- data/logo.lua | 8 +++---- data/main.lua | 4 ++-- data/opcions.lua | 14 ++++++------ data/opcions_input.lua | 12 +++++----- data/peu.lua | 2 +- data/scenes.lua | 12 +++++----- data/stage1.lua | 30 ++++++++++++++++--------- data/stage1_ending.lua | 11 +++++---- data/{flow.lua => states.lua} | 42 +++++++++++++++++------------------ data/title.lua | 8 +++---- data/trigger.lua | 6 ++--- data/trigger_event.lua | 16 +++++++++---- 16 files changed, 105 insertions(+), 80 deletions(-) rename data/{flow.lua => states.lua} (77%) diff --git a/data/batvio.lua b/data/batvio.lua index ea9694b..4d299ea 100644 --- a/data/batvio.lua +++ b/data/batvio.lua @@ -26,9 +26,8 @@ batvio={ d_angle=15, dying=false, death_time=40, - enabled=true, + enabled=false, disable_reason="", - enabled=true, } function batvio.init() @@ -38,6 +37,8 @@ function batvio.init() end function batvio.draw() + if not batvio.enabled then return end + local curr_sf = surf.source() surf.source(tiles2) local scr_x, scr_y = viewp:screen_coords( batvio.x, batvio.y ) @@ -66,5 +67,7 @@ function batvio.hit() end function batvio.update() + if not batvio.enabled then return end + batvio.step = batvio.step +1 end \ No newline at end of file diff --git a/data/bol.lua b/data/bol.lua index de557cc..c09b355 100644 --- a/data/bol.lua +++ b/data/bol.lua @@ -67,6 +67,7 @@ function bol.update() remove_actor(bol) -- crear el trigger per a disparar el final de fase table.insert( actors, trigger.new(8,4,3,triggers.escena_stage1_ending,"stage1 ending","TR09") ) + batvio.enabled = true end end end diff --git a/data/game.lua b/data/game.lua index 6fbcf4f..4859816 100644 --- a/data/game.lua +++ b/data/game.lua @@ -130,7 +130,7 @@ function game_init(menu) score.create() -- game_update=update_game - flow:next() + states:next() end @@ -521,4 +521,4 @@ function debug_info() font.current(font_sf) end -flow:registrar("game", {game_init, update_game} ) +states:registrar("game", {game_init, update_game} ) diff --git a/data/intro.lua b/data/intro.lua index 66df359..8b9662a 100644 --- a/data/intro.lua +++ b/data/intro.lua @@ -47,13 +47,13 @@ print("INTRO_INIT") fade.fadein() font.current(font_sf) -- flow:add_path({intro_intro, intro_update}) - flow:next() + states:next() end function intro_intro() intro_wait=1 -- game_update = intro_update - flow:next() + states:next() fade.fadeoutin() end @@ -135,7 +135,7 @@ end function intro_end() print("intro_end") fade.fadeoutin() - flow:executar("title") + states:executar("title") end -flow:registrar("intro", {intro_init, intro_intro, intro_update}) \ No newline at end of file +states:registrar("intro", {intro_init, intro_intro, intro_update}) \ No newline at end of file diff --git a/data/logo.lua b/data/logo.lua index 905727a..5b7f753 100644 --- a/data/logo.lua +++ b/data/logo.lua @@ -49,7 +49,7 @@ function logo_init() -- Següent bucle -- game_update = logo_intro - local modul, pas=flow:next() + local modul, pas=states:next() print("LOGO_INIT= "..modul..", "..pas) end @@ -175,7 +175,7 @@ function logo_end() -- print("LOGO_END") -- game_update = intro_init print("logo_end") - flow:executar("intro") + states:executar("intro") -- surf.free(logo_sf) end @@ -185,7 +185,7 @@ function logo_animate() -- Següent bucle if logo_step==7 or controller:check("ESC") or controller:check("shoot") then - local modul, pas=flow:next() + local modul, pas=states:next() -- print("LOGO_ANIMATE 1= "..modul..", "..pas) end @@ -193,4 +193,4 @@ function logo_animate() logo_update() end -flow:registrar("logo",{logo_init, logo_animate, logo_end}) +states:registrar("logo",{logo_init, logo_animate, logo_end}) diff --git a/data/main.lua b/data/main.lua index d3f6a6b..290ef61 100644 --- a/data/main.lua +++ b/data/main.lua @@ -2,7 +2,7 @@ arcade_config = require("arcade_config") coords = require "coords" require "helpers" require "controller" -require "flow" +require "states" require "map" require "mapa" @@ -88,7 +88,7 @@ function mini.init() logo_config(font_sf) surf.target(0) surf.cls(16) - flow:executar("game") + states:executar("logo") end function mini.update() diff --git a/data/opcions.lua b/data/opcions.lua index b1a20af..ff604db 100644 --- a/data/opcions.lua +++ b/data/opcions.lua @@ -2,7 +2,7 @@ local menu_sel = 0 function opcions_init() -- flow:add_path({opcions_show, opcions_end}) - flow:next() + states:next() end function opcions_draw() @@ -27,14 +27,14 @@ function opcions_update() elseif menu_sel==2 then -- menu_count=0 -- menu_state=update_redefine_keys_menu - flow:executar("opcions_teclat", true) + states:executar("opcions_teclat", true) elseif menu_sel==3 then -- menu_count=0 -- menu_state=update_redefine_pad_menu - flow:executar("opcions_gamepad", true) + states:executar("opcions_gamepad", true) else -- Tornar - flow:next() + states:next() end elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then menu_sel=menu_sel+1 @@ -44,7 +44,7 @@ function opcions_update() if menu_sel==-1 then menu_sel=4 end elseif key.press(key.ESCAPE) or pad.press(btnPause) then -- Tornar desde qualsevol lloc - flow:next() + states:next() end end @@ -56,7 +56,7 @@ end function opcions_end() print("opcions_end") -- flow:restore() - flow:finish() + states:finish() end -flow:registrar("opcions",{opcions_init, opcions_show, opcions_end}) +states:registrar("opcions",{opcions_init, opcions_show, opcions_end}) diff --git a/data/opcions_input.lua b/data/opcions_input.lua index 725f6f0..197fa6f 100644 --- a/data/opcions_input.lua +++ b/data/opcions_input.lua @@ -20,7 +20,7 @@ function opcions_input_init() surf.target(0) surf.cls(16) menu_opt = 1 - flow:next() + states:next() end function opcions_input_draw() @@ -70,7 +70,7 @@ function opcions_input_update() local curr_key = input_keys[menu_opt] if key.press(key.ESCAPE) then - flow:next() + states:next() return end @@ -99,7 +99,7 @@ end function opcions_input_end() menu_opt = 0 - flow:finish() + states:finish() end function config_key(def_key, k) @@ -120,8 +120,8 @@ function config_key(def_key, k) print("ERROR AL DEFINIR") end - if end_setup then flow:next() end + if end_setup then states:next() end end -flow:registrar("opcions_teclat", { opcions_teclat_init, opcions_input_show, opcions_input_end } ) -flow:registrar("opcions_gamepad", { opcions_gamepad_init, opcions_input_show, opcions_input_end } ) \ No newline at end of file +states:registrar("opcions_teclat", { opcions_teclat_init, opcions_input_show, opcions_input_end } ) +states:registrar("opcions_gamepad", { opcions_gamepad_init, opcions_input_show, opcions_input_end } ) \ No newline at end of file diff --git a/data/peu.lua b/data/peu.lua index 2909f06..79d3788 100644 --- a/data/peu.lua +++ b/data/peu.lua @@ -11,7 +11,7 @@ peu={name="peu",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}} function peu.init() -- local habs={{18,8},{16,2},{16,7},{15,5},{27,1},{27,10},{29,2},{38,8},{69,2},{79,3}} - local habs={{69,0},{78,6},{59,8},{27,8},{16,0},{18,8}} + local habs={{69,0},{78,6},{59,8},{27,9},{16,0},{18,8}} local r=1+math.random(0,#habs-1) peu.hab=habs[r][1] -- peu.x=habs[r][2]*8 diff --git a/data/scenes.lua b/data/scenes.lua index e837a33..18dc7a1 100644 --- a/data/scenes.lua +++ b/data/scenes.lua @@ -214,7 +214,7 @@ function start_scene(_scene, offset, stop_music) scene.running = true if not stop_music then scene.stop_music = false end print("SCENE START") - flow:executar("scene", true); -- guardar l'estat anterior i executar + states:executar("scene", true); -- guardar l'estat anterior i executar end function playtext(snd) @@ -399,7 +399,7 @@ function update_scene() -- else -- game_update=old_update -- flow:restore() - flow:next() + states:next() -- end else next_scene() @@ -420,7 +420,7 @@ function update_scene() -- game_init(true) -- flow:next() -- game_update = menu_init - flow:executar("title") + states:executar("title") else pause() end @@ -437,7 +437,7 @@ function update_scene() -- fade.fadeoutin() -- else -- game_update=old_update - flow:next() + states:next() -- end else -- scenes.dnum=scenes.dnum+1 @@ -452,7 +452,7 @@ end function end_scene() scene.running = false - flow:finish() + states:finish() end -flow:registrar("scene",{update_scene, end_scene}) \ No newline at end of file +states:registrar("scene",{update_scene, end_scene}) \ No newline at end of file diff --git a/data/stage1.lua b/data/stage1.lua index e094dfe..421d2f7 100644 --- a/data/stage1.lua +++ b/data/stage1.lua @@ -141,25 +141,31 @@ function stages.stage1_init() trigger_ev.dialeg_trigger, trigger_ev.dialeg_init, nil, - premiere, abad, 150, "Ma que cosa fare", 150) + premiere, abad, 150, "Ma que cosa fare", 150, 0, true) trigger_event.new("Zombie 1 dialeg", trigger_ev.dialeg_trigger, trigger_ev.dialeg_init, nil, - zombie1, abad, 150, "Sereeeeebrooooosssss", 250) + zombie1, abad, 150, "Sereeeeebrooooosssss", 250, nil, true) trigger_event.new("Zombie 2 dialeg", trigger_ev.dialeg_trigger, trigger_ev.dialeg_init, nil, - zombie2, abad, 150, "Aaaaaargh... per ell!", 250) + zombie2, abad, 150, "Aaaaaargh... per ell!", 250, nil, true) trigger_event.new("Elalien dialeg", trigger_ev.dialeg_trigger, trigger_ev.dialeg_init, nil, - elalien, abad, 150, "I les tisores de podar?", 250) + elalien, abad, 150, "I les tisores de podar?", 250, nil, true) + + trigger_event.new("Abad dialeg", + trigger_ev.dialeg_trigger, + trigger_ev.dialeg_init, + nil, + abad, bol, 150, "Mmmm fa olor a cacaus...", 80, 49, false) tiles_layer2.new(13,11,3,144,144,16,16) tiles_layer2.new(13,11,4,144,144,16,16) @@ -169,8 +175,8 @@ function stages.stage1_init() local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 ) -- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 ) - table.insert( actors, trigger.new(8,4,3,triggers.escena_stage1_ending,"stage1 ending","TR09") ) - local abad_x, abad_y = coords.room_to_world ( 8, 9, 3 ) + -- table.insert( actors, trigger.new(8,4,3,triggers.escena_stage1_ending,"stage1 ending","TR09") ) + -- local abad_x, abad_y = coords.room_to_world ( 8, 9, 3 ) abad:move(abad_x, abad_y) abad_make_safe( true ) @@ -253,7 +259,8 @@ stage1_mapa={ -- 1 { 256,256,256,18,19,21,20,21,20,21,20,21, - 64,68,256,16,72,256,256,256,256,256,256,256, + -- 64,68,256,16,72,256,256,256,256,256,256,256, + 64,256,256,16,72,256,256,256,256,256,256,256, 256,256,66,256,88,256,256,70,71,256,256,256, 256,66,256,16,256,112,256,86,87,256,114,256, 66,256,256,16,256,256,256,256,256,256,256,256, @@ -313,7 +320,8 @@ stage1_mapa={ -- 7 { 42,43,256,256,256,256,65,256,256,256,256,64, - 256,41,256,67,256,256,256,256,68,256,256,256, + -- 256,41,256,67,256,256,256,256,68,256,256,256, + 256,41,256,67,256,256,256,256,256,256,256,256, 256,41,256,256,256,66,256,256,256,256,256,256, 256,256,256,64,256,256,65,256,67,256,67,256, 256,256,256,256,256,256,256,256,256,256,256,256, @@ -810,7 +818,8 @@ stage1_mapa={ -- 54 { 20,21,20,21,21,17,18,19,67,256,256,256, - 256,256,256,256,256,17,18,19,256,65,68,64, + -- 256,256,256,256,256,17,18,19,256,65,68,64, + 256,256,256,256,256,17,18,19,256,65,256,64, 256,256,256,256,256,256,18,19,256,256,256,256, 256,256,256,256,256,256,38,256,67,256,64,256, 256,256,256,256,256,256,38,256,256,256,256,256, @@ -830,7 +839,8 @@ stage1_mapa={ -- 56 { 65,256,256,256,67,256,67,256,256,256,256,64, - 256,256,64,256,256,256,256,65,68,64,256,256, + -- 256,256,64,256,256,256,256,65,68,64,256,256, + 256,256,64,256,256,256,256,65,256,64,256,256, 256,256,256,256,256,64,256,256,256,256,67,256, 256,65,67,256,256,64,256,256,64,256,256,256, 256,256,256,256,256,256,256,256,256,256,256,256, diff --git a/data/stage1_ending.lua b/data/stage1_ending.lua index 5da78f4..45ada9e 100644 --- a/data/stage1_ending.lua +++ b/data/stage1_ending.lua @@ -47,12 +47,15 @@ function stage1_ending.update_scene(self) table.insert( actors, copter) music.play(audio_song_copter) elseif self.time<720 then + -- sisena escena - premiere copter premiere.update() copter.x = premiere.x-32 copter.y = premiere.y-48 copter.update() elseif self.time==720 then - start_scene(scenes.stage1_ending_3, nil, false) + start_scene(scenes.stage1_ending_3, nil, false) + elseif self.time==721 then + fade.fadeoutin() end surf.target(0) @@ -76,16 +79,16 @@ function stage1_ending.update_scene(self) -- Acabar ending if self.time>=800 then - flow:next() + states:next() end end function stage1_ending.end_scene() print("END") - flow:finish() + states:finish() end -flow:registrar("stage1_ending",{ +states:registrar("stage1_ending",{ stage1_ending.update, stage1_ending.end_scene }) \ No newline at end of file diff --git a/data/flow.lua b/data/states.lua similarity index 77% rename from data/flow.lua rename to data/states.lua index 53b1249..4cb5b43 100644 --- a/data/flow.lua +++ b/data/states.lua @@ -21,7 +21,7 @@ -- print("") -- end -flow={ +states={ registre={}, -- {nom {ptr (a l'estat actual), path (llista de funcions ordenada)} ...} actiu = "", -- nom del registre actiu stack = {}, -- guarda els canvis de registre per a poder tornar a l'estat anterior @@ -30,31 +30,31 @@ flow={ } -function flow:safe() - if not flow.safe_show then - print("[FLOW] No hi ha res en la pila") - flow.safe_show = true +function states:safe() + if not states.safe_show then + print("[STATES] No hi ha res en la pila") + states.safe_show = true end end -function flow:registrar(nom, _path) - print("[FLOW] REGISTRAR => "..nom) +function states:registrar(nom, _path) + print("[STATES] REGISTRAR => "..nom) self.registre[nom]= {ptr=0, path=_path} print(self.registre[nom].ptr) end -function flow:borrar(nom) +function states:borrar(nom) self.registre[nom].ptr=0 self.registre[nom].path=nil end -function flow:add(nom) - print("[FLOW] add "..nom) +function states:add(nom) + print("[STATES] add "..nom) self.add_stack[#self.add_stack+1] = nom end -function flow:executar(nom, stacking) - print("[FLOW] EXEC "..nom) +function states:executar(nom, stacking) + print("[STATES] EXEC "..nom) if stacking then -- table.insert(self.stack, self.actiu) self.stack[#self.stack+1] = self.actiu @@ -71,11 +71,11 @@ function flow:executar(nom, stacking) self:next() end -function flow:next() - print("[FLOW] NEXT "..self.actiu); +function states:next() + print("[STATES] NEXT "..self.actiu); local ptr = self.registre[self.actiu].ptr local steps = #self.registre[self.actiu].path --- print("FLOW_NEXT= "..self.actiu..", "..ptr..", "..steps) +-- print("STATES_NEXT= "..self.actiu..", "..ptr..", "..steps) if ptr+1>steps then self:finish() else @@ -86,13 +86,13 @@ function flow:next() return self.actiu, self.registre[self.actiu].ptr end -function flow:finish() - print("[FLOW] FINISH "..self.actiu); +function states:finish() + print("[STATES] FINISH "..self.actiu); self.actiu = table.remove(self.stack) - print("[FLOW] ACTIU "..self.actiu); + print("[STATES] ACTIU "..self.actiu); if self.actiu==nil then -- no queda res en la pila - self.actiu="flow" + self.actiu="states" self.registre[self.actiu].ptr = 1 else -- ultim element afegit a la pila @@ -104,9 +104,9 @@ function flow:finish() self.registre[self.actiu].ptr = 1 end end - local curr_flow = self.registre[self.actiu] + local curr_states = self.registre[self.actiu] local ptr = self.registre[self.actiu].ptr game_update = self.registre[self.actiu].path[self.registre[self.actiu].ptr] end -flow:registrar("flow",{flow.safe}) +states:registrar("states",{states.safe}) diff --git a/data/title.lua b/data/title.lua index a26ba48..c17c6ab 100644 --- a/data/title.lua +++ b/data/title.lua @@ -33,7 +33,7 @@ function title_init() title_sf=surf.load("title_tiles.gif") surf.source(title_sf) music.play(audio_main_song) - flow:next() + states:next() end function title_draw_frame () @@ -164,12 +164,12 @@ end function to_game() print("to game") fade.fadeoutin() - flow:executar("game") + states:executar("game") end function to_options() print("to options") - flow:executar("opcions", true) + states:executar("opcions", true) end -flow:registrar("title", {title_init, title_show, title_end}) +states:registrar("title", {title_init, title_show, title_end}) diff --git a/data/trigger.lua b/data/trigger.lua index 4b6ff94..49f0d8e 100644 --- a/data/trigger.lua +++ b/data/trigger.lua @@ -124,8 +124,8 @@ function triggers:escena_abad_porta_batman() end function triggers:escena_habitacio_batman() - if abad.objects.clau_premiere==nil and - abad.objects.clau_elalien==nil + if abad.objects.clau_premiere~=nil and + abad.objects.clau_elalien~=nil then -- switches.start(0,0) local trigger_porta = trigger.new(abad.hab,1,1,triggers.open_door,"switch","porta acces cacaus","",{20, 53,41}) @@ -146,7 +146,7 @@ function triggers:escena_stage1_ending() print("STAGE 1 ENDING") -- abad.update = abad_nop remove_actor(self) - flow:executar("stage1_ending", true) + states:executar("stage1_ending", true) -- live_scene.start("stage1_ending", "add") -- start_scene(scenes.stage1_ending, nil, false) end diff --git a/data/trigger_event.lua b/data/trigger_event.lua index e8aba27..7982581 100644 --- a/data/trigger_event.lua +++ b/data/trigger_event.lua @@ -4,7 +4,7 @@ trigger_event = { trigger_ev = {} -function trigger_event.new ( _name, _tr_func, _tr_init, _tr_update, _a, _b, _time, _text, _distancia ) +function trigger_event.new ( _name, _tr_func, _tr_init, _tr_update, _a, _b, _time, _text, _distancia, _hab, _collision_req ) table.insert( trigger_event.list, { name = _name, trigger = _tr_func, @@ -14,8 +14,10 @@ function trigger_event.new ( _name, _tr_func, _tr_init, _tr_update, _a, _b, _tim actor_b = _b, time = _time, text = _text, + hab = _hab, distancia = _distancia, enabled = true, + collision_req = _collision_req, running = false, }) end @@ -125,9 +127,15 @@ end -- DIALEG GENERAL function trigger_ev:dialeg_trigger () - if h_collision( self.actor, self.actor_b ) and - distancia ( self.actor, self.actor_b )<=self.distancia - then + local in_hab = false + if (self.hab~=nil and self.hab==self.actor.hab) or self.hab==nil then in_hab=true end + + local is_collision = true + if self.collision_req then + is_collision = h_collision( self.actor, self.actor_b ) + end + + if in_hab and is_collision and distancia ( self.actor, self.actor_b )<=self.distancia then self:init() return true end