Files
cacaus/trigger.lua

49 lines
1.1 KiB
Lua

trigger={}
function trigger.new(_hab,_x,_y,_fun)
return {hab=_hab,x=_x,y=_y,fun=_fun,update=trigger.update,draw=trigger.draw,bb={x=0,y=0,w=8,h=8}}
end
function trigger:draw()
-- do nothing
--rectfill(self.x,self.y,self.x+8,self.y+8,3)
end
function trigger:update()
if self.hab==abad.hab then
if aabb(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_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