Switches funcionant
This commit is contained in:
@@ -166,8 +166,13 @@ function abad_jump()
|
||||
-- Fer l'acció que correspon
|
||||
if not_block_tile then
|
||||
if switch_tile then
|
||||
local xx= x2_check
|
||||
local yy= y_check
|
||||
-- Executar el switch
|
||||
switches.start(abad.hab,1+xx+yy*12)
|
||||
if tile1_hit_type == tiletype.switch then
|
||||
xx= x1_check
|
||||
end
|
||||
switches.start(xx, yy)
|
||||
else
|
||||
abad.y=abad.y-vspace
|
||||
end
|
||||
|
||||
@@ -21,12 +21,13 @@ viewp:position(0,0)
|
||||
actors={}
|
||||
|
||||
function game_init(menu)
|
||||
|
||||
abad_init()
|
||||
table.insert(actors,abad)
|
||||
|
||||
local abad_x, abad_y = arc_mapa_get_coords ( 10, 4, 3 )
|
||||
print(abad_x..", "..abad_y)
|
||||
-- print(abad_x..", "..abad_y)
|
||||
abad:move(abad_x, abad_y)
|
||||
|
||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||
|
||||
game_update=update_game
|
||||
@@ -88,6 +89,8 @@ function update_game()
|
||||
-- if vp_y+1<=(tile_h*mapa_room_rows*mapa_pisos)-(res_h) then vp_y = vp_y+1 end
|
||||
--end
|
||||
|
||||
load_tilemap( sf_mapa )
|
||||
|
||||
if key.press(key.N1) then
|
||||
local hab = math.random(0, 79)
|
||||
local hab_x = math.random(0, mapa_room_cols-1)
|
||||
@@ -114,6 +117,8 @@ function update_game()
|
||||
-- end
|
||||
--end
|
||||
end
|
||||
switches.update()
|
||||
|
||||
local vp_x = viewp.x
|
||||
local vp_y = viewp.y
|
||||
--viewp:position(vp_x, vp_y)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
require "fade"
|
||||
require "audio"
|
||||
require "intro"
|
||||
require "switches"
|
||||
require "map"
|
||||
|
||||
local arcade_config = require("arcade_config")
|
||||
|
||||
@@ -124,6 +124,7 @@ function mapa_set_tile(hab,x,y,tile)
|
||||
end
|
||||
|
||||
function mapa_set_tile_by_index(hab,index,tile)
|
||||
print("MSTBI= R"..hab..", I"..index..", T="..mapa[1+hab][index].." -> "..tile)
|
||||
mapa[1+hab][index]=tile
|
||||
end
|
||||
|
||||
|
||||
47
data/switches.lua
Normal file
47
data/switches.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
switches={
|
||||
cooldown=0,
|
||||
wait=0,
|
||||
current_list=nil,
|
||||
current_index=-1,
|
||||
[1]={[0]={20, 53,41}},
|
||||
[11]={[21]={11, 57,45}},
|
||||
[35]={[14]={32, 50,38,26,53,41,29}},
|
||||
[53]={[14]={72, 42,30}},
|
||||
[61]={[14]={54, 54,42}},
|
||||
[76]={[19]={77, 50,38,26},
|
||||
[22]={57, 53,41}},
|
||||
[80]={[18]={36, 56,44}},
|
||||
[39]={[27]={39, 62,63}}
|
||||
}
|
||||
--switches[11]={[21]={11, 57,45}}
|
||||
--switches[11][21]={11, 57,45}
|
||||
|
||||
function switches.start(x, y)
|
||||
if switches.cooldown>0 then return end
|
||||
local hab, hx, hy = arc_mapa_get_map_coords(x, y)
|
||||
local tile_idx = (hx+hy*mapa_room_cols)+1
|
||||
print("Switch > "..x..", "..y.." / "..hab..", "..hx..", "..hy.." T="..tile_idx)
|
||||
mapa_set_tile_by_index(hab,tile_idx,57)
|
||||
switches.current_list=switches[hab+1][tile_idx]
|
||||
switches.current_index=2
|
||||
switches.wait=0
|
||||
switches.cooldown=60
|
||||
sound.play(audio_switch)
|
||||
end
|
||||
|
||||
function switches.update()
|
||||
if switches.cooldown>0 then switches.cooldown=switches.cooldown-1 end
|
||||
if switches.current_list==nil then return end
|
||||
--cls(4)
|
||||
|
||||
switches.wait=switches.wait+1
|
||||
|
||||
if switches.wait>=6 then
|
||||
switches.wait=0
|
||||
mapa_set_tile_by_index(switches.current_list[1]-1,switches.current_list[switches.current_index]+1,256)
|
||||
switches.current_index=switches.current_index+1
|
||||
if switches.current_index>#switches.current_list then
|
||||
switches.current_list=nil
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user