Triggers en marxa
This commit is contained in:
@@ -92,7 +92,7 @@ function game_exit()
|
||||
end
|
||||
|
||||
function game_init(menu)
|
||||
print("GAME INIT")
|
||||
-- print("GAME INIT")
|
||||
actors={}
|
||||
|
||||
abad_init()
|
||||
@@ -158,17 +158,17 @@ print("GAME INIT")
|
||||
|
||||
-- TRIGGERS
|
||||
-- if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end
|
||||
table.insert( actors, trigger.new(10,7,3,triggers.escena_abad_inici))
|
||||
-- table.insert(actors,trigger.new(11,16,32,triggers.escena_abad_corfes))
|
||||
--
|
||||
-- table.insert(actors,trigger.new(31,12,32,triggers.escena_abad_portes))
|
||||
-- table.insert(actors,trigger.new(31,48,32,triggers.escena_abad_portes))
|
||||
-- table.insert(actors,trigger.new(71,56,24,triggers.escena_abad_portes))
|
||||
--
|
||||
-- table.insert(actors,trigger.new(53,40,32,triggers.escena_abad_porta_casa))
|
||||
-- table.insert(actors,trigger.new(56,32,32,triggers.escena_abad_porta_batman))
|
||||
--
|
||||
-- table.insert(actors,trigger.new(19,32,32,triggers.escena_habitacio_batman))
|
||||
table.insert( actors, trigger.new(10,7,3,triggers.escena_abad_inici,"inici"))
|
||||
table.insert( actors, trigger.new(11,2,3,triggers.escena_abad_corfes,"corfes"))
|
||||
|
||||
table.insert( actors, trigger.new(31,1,3,triggers.escena_abad_portes,"portes"))
|
||||
table.insert( actors, trigger.new(31,6,3,triggers.escena_abad_portes,"portes"))
|
||||
table.insert( actors, trigger.new(71,7,3,triggers.escena_abad_portes,"portes"))
|
||||
|
||||
table.insert( actors, trigger.new(53,5,3,triggers.escena_abad_porta_casa,"porta casa"))
|
||||
table.insert( actors, trigger.new(56,4,3,triggers.escena_abad_porta_batman,"porta batman"))
|
||||
|
||||
table.insert( actors, trigger.new(19,32,32,triggers.escena_habitacio_batman,"habitacio batman"))
|
||||
--
|
||||
-- table.insert(actors,trigger.new(14,40,32,triggers.teleport_a))
|
||||
-- table.insert(actors,trigger.new(67,8,32,triggers.teleport_b))
|
||||
@@ -183,7 +183,8 @@ print("GAME INIT")
|
||||
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
|
||||
game_update=update_game
|
||||
-- game_update=update_game
|
||||
flow:next()
|
||||
end
|
||||
|
||||
function render_map( sf_map, sf_tiles, x, y )
|
||||
@@ -200,48 +201,6 @@ function update_game()
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
|
||||
-- surf.target(logo)
|
||||
-- surf.cls(16)
|
||||
-- draw.text("UPDATE_GAME",0,0,15)
|
||||
-- surf.source(logo)
|
||||
-- draw.surf(0,0,36,5,56,70,arcade_config.logo_sf.width,arcade_config.logo_sf.height)
|
||||
|
||||
--- if abad.hurting == 0 then
|
||||
--- draw_hab(abad.hab,0,0)
|
||||
--- --text(abad.hab,1,1,2)
|
||||
--- draw_hab(cameras[current_camera].hab,0,48)
|
||||
--- -- text(camera_names[current_camera],2*o2aX,49*o2aX,8)
|
||||
--- arc_textB(camera_names[current_camera],2*o2aX,49*o2aX,8)
|
||||
---
|
||||
--- score.draw()
|
||||
--- surf.source(tiles)
|
||||
--- -- draw.text("x"..abad.vides,114*o2aX,13*o2aX,2)
|
||||
--- arc_text("x"..abad.vides,114*o2aX,13*o2aX,2)
|
||||
--- draw.rectf((102+(abad.energia>>1))*o2aX,30*o2aX,(21-(abad.energia>>1))*o2aX,8*o2aX,16)
|
||||
--- else
|
||||
--- draw.surf(0,0,16*o2aX,9*o2aX,50*o2aX,40*o2aX,16*o2aX,9*o2aX,true)
|
||||
--- if abad.hurting > 40 then
|
||||
--- -- draw.text("x"..abad.vides+1,63*o2aX,43*o2aX,3)
|
||||
--- arc_text("x"..abad.vides+1,63*o2aX,43*o2aX,3)
|
||||
--- elseif abad.hurting < 20 then
|
||||
--- -- draw.text("x"..abad.vides,63*o2aX,43*o2aX,2)
|
||||
--- arc_text("x"..abad.vides,63*o2aX,43*o2aX,2)
|
||||
--- end
|
||||
--- end
|
||||
---
|
||||
--- mapa_update(abad.hab,cameras[current_camera].hab)
|
||||
|
||||
--local vp_x, vp_y = viewp:position()
|
||||
--if key.down(keyRight) then
|
||||
-- if vp_x+1<=(tile_w*mapa_room_cols*(mapa_rooms_per_piso))-(res_w) then vp_x = vp_x+1 end
|
||||
--elseif key.down(keyLeft) then
|
||||
-- if vp_x>0 then vp_x = vp_x-1 end
|
||||
--elseif key.down(keyUp) then
|
||||
-- if vp_y>0 then vp_y = vp_y -1 end
|
||||
--elseif key.down(keyDown) then
|
||||
-- if vp_y+1<=(tile_h*mapa_room_rows*mapa_pisos)-(res_h) then vp_y = vp_y+1 end
|
||||
--end
|
||||
|
||||
if key.press(key.N1) then
|
||||
local hab = abad.hab-1
|
||||
if hab<0 then hab=0 end
|
||||
@@ -261,7 +220,7 @@ function update_game()
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
end
|
||||
if key.press(key.N0) then
|
||||
local abad_x, abad_y = coords.room_to_world ( 58, 3, 3 )
|
||||
local abad_x, abad_y = coords.room_to_world ( 53, 3, 3 )
|
||||
print(abad_x..", "..abad_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
@@ -373,4 +332,4 @@ function update_game()
|
||||
-- end
|
||||
end
|
||||
|
||||
flow:registrar("game", {game_init})
|
||||
flow:registrar("game", {game_init, update_game} )
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
trigger={}
|
||||
|
||||
function trigger.new(_hab,_x,_y,_fun)
|
||||
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,
|
||||
@@ -46,7 +47,11 @@ function triggers:escena_abad_corfes()
|
||||
end
|
||||
|
||||
function triggers:escena_abad_portes()
|
||||
if abad.escena_portes==nil and ((abad.hab==31 and mapa_get_tile(abad.hab,2,4)~=256) or (abad.hab==71 and mapa_get_tile(abad.hab,6,3)~=256)) then
|
||||
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
|
||||
@@ -54,14 +59,16 @@ function triggers:escena_abad_portes()
|
||||
end
|
||||
|
||||
function triggers:escena_abad_porta_casa()
|
||||
if mapa_get_tile(abad.hab,6,4)~=256 then
|
||||
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()
|
||||
if mapa_get_tile(abad.hab,5,4)~=256 then
|
||||
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)
|
||||
@@ -81,40 +88,40 @@ function triggers:escena_habitacio_batman()
|
||||
end
|
||||
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
|
||||
-- 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
|
||||
|
||||
Reference in New Issue
Block a user