trigger={} function trigger.new(_hab,_x,_y,_fun,_escena) local world_x, world_y = coords.room_to_world(_hab,_x,_y) return { name="trigger", escena=_escena, hab=_hab, x=world_x, y=world_y, w=16, h=16, fun=_fun, update=trigger.update, draw=trigger.draw, bb={x=0,y=0,w=16,h=16} } end function trigger:draw() -- do nothing local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) draw.rect(scr_x,scr_y,self.w,self.h,3) end function trigger:update() if self.hab==abad.hab then if collision(abad,self) then self:fun() end end end --function trigger:do_touched() -- start_scene(self.scene) -- remove_actor(self) --end triggers={} function triggers:escena_abad_inici() start_scene(scenes.abad_inici) remove_actor(self) end function triggers:escena_abad_corfes() start_scene(scenes.abad_corfes) remove_actor(self) end function triggers:escena_abad_portes() local wx1,wy1 = coords.room_to_world(abad.hab,2,4) local wx2,wy2 = coords.room_to_world(abad.hab,6,3) if abad.escena_portes==nil and ( (abad.hab==31 and arc_get_tile(wx1,wy1)~=256) or (abad.hab==71 and arc_get_tile(wx2,wy2)~=256) ) then start_scene(scenes.abad_portes) end abad.escena_portes=true remove_actor(self) end function triggers:escena_abad_porta_casa() local wx1,wy1 = coords.room_to_world(abad.hab,6,4) if arc_get_tile(wx1,wy1)~=256 then start_scene(scenes.abad_porta_casa) end remove_actor(self) end function triggers:escena_abad_porta_batman() local wx1,wy1 = coords.room_to_world(abad.hab,5,4) if arc_get_tile(wx1,wy1)~=256 then start_scene(scenes.abad_porta_batman) end remove_actor(self) end function triggers:escena_habitacio_batman() if abad.objects.clau_premiere~=nil and abad.objects.clau_elalien~=nil then switches.start(0,0) abad.objects.clau_premiere=nil abad.objects.clau_elalien=nil remove_actor(self) else if batman.habitacio_porta_intro==nil then start_scene(scenes.habitacio_batman) batman.habitacio_porta_intro=true end end end function triggers:escena_lluita_imp() start_scene(scenes.lluita_imp) remove_actor(self) end -- function triggers:teleport_a() -- abad.teleport=true -- sound.play(audio_hit) -- surf.cls(14) -- imp.reset() -- abad.hab=67 -- abad.x=24 -- end -- -- function triggers:teleport_b() -- if abad.teleport then -- sound.play(audio_hit) -- surf.cls(14) -- imp.reset() -- abad.hab=14 -- abad.x=16 -- end -- end -- -- function triggers:teleport_c() -- abad.teleport2=true -- sound.play(audio_hit) -- surf.cls(14) -- imp.reset() -- abad.hab=61 -- abad.x=24 -- end -- -- function triggers:teleport_d() -- if abad.teleport2 then -- sound.play(audio_hit) -- surf.cls(14) -- imp.reset() -- abad.hab=29 -- abad.x=24 -- end -- end