Compare commits
2 Commits
2fb0749cf7
...
d8dce7dfed
| Author | SHA1 | Date | |
|---|---|---|---|
| d8dce7dfed | |||
| db844e634c |
@@ -6,6 +6,15 @@ actors={
|
||||
table.insert(actors.list, actor)
|
||||
end,
|
||||
|
||||
remove=function(name)
|
||||
for i,v in ipairs(actors.list) do
|
||||
if v.name and v.name==name then
|
||||
table.remove(actors.list,i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
search=function(name)
|
||||
for i,v in ipairs(actors.list) do
|
||||
if v.name and v.name==name then
|
||||
@@ -35,48 +44,50 @@ actors={
|
||||
for i,v in ipairs(actors.list) do
|
||||
if v.dx==0 and v.dy==0 then
|
||||
if v.path then
|
||||
v.path.pos=v.path.pos+1
|
||||
local step=string.sub(v.path.route,v.path.pos,v.path.pos)
|
||||
if step=='u' then
|
||||
--check collision!
|
||||
v.y=v.y-1
|
||||
v.dy=4
|
||||
v.o='u'
|
||||
needs_sorting=true
|
||||
elseif step=='d' then
|
||||
--check collision!
|
||||
v.y=v.y+1
|
||||
v.dy=-4
|
||||
v.o='d'
|
||||
needs_sorting=true
|
||||
elseif step=='l' then
|
||||
--check collision!
|
||||
v.x=v.x-1
|
||||
v.dx=4
|
||||
v.o='l'
|
||||
elseif step=='r' then
|
||||
--check collision!
|
||||
v.x=v.x+1
|
||||
v.dx=-4
|
||||
v.o='r'
|
||||
elseif step=='q' then
|
||||
v.o='u'
|
||||
elseif step=='a' then
|
||||
v.o='d'
|
||||
elseif step=='o' then
|
||||
v.o='l'
|
||||
elseif step=='p' then
|
||||
v.o='r'
|
||||
end
|
||||
|
||||
if v.path.pos == #v.path.route then
|
||||
local in_scene = not v.path.keys
|
||||
v.path=nil
|
||||
game.update()
|
||||
scene.cont()
|
||||
if in_scene then scene.cont() end
|
||||
v.keys=nil
|
||||
if v.name == actors.hero then
|
||||
local switch = switches.search(v.x,v.y)
|
||||
if switch then switch.action() end
|
||||
end
|
||||
else
|
||||
v.path.pos=v.path.pos+1
|
||||
local step=string.sub(v.path.route,v.path.pos,v.path.pos)
|
||||
if step=='u' then
|
||||
v.o='u'
|
||||
--check collision!
|
||||
v.y=v.y-1
|
||||
v.dy=4
|
||||
needs_sorting=true
|
||||
elseif step=='d' then
|
||||
v.o='d'
|
||||
--check collision!
|
||||
v.y=v.y+1
|
||||
v.dy=-4
|
||||
needs_sorting=true
|
||||
elseif step=='l' then
|
||||
v.o='l'
|
||||
--check collision!
|
||||
v.x=v.x-1
|
||||
v.dx=4
|
||||
elseif step=='r' then
|
||||
v.o='r'
|
||||
--check collision!
|
||||
v.x=v.x+1
|
||||
v.dx=-4
|
||||
elseif step=='q' then
|
||||
v.o='u'
|
||||
elseif step=='a' then
|
||||
v.o='d'
|
||||
elseif step=='o' then
|
||||
v.o='l'
|
||||
elseif step=='p' then
|
||||
v.o='r'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,4 +3,4 @@ config=ja2
|
||||
width=160
|
||||
height=144
|
||||
zoom=5
|
||||
files=switches.lua,scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua
|
||||
files=wait.lua,switches.lua,scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua
|
||||
|
||||
@@ -4,7 +4,7 @@ game={
|
||||
init=function()
|
||||
flags={}
|
||||
mapa.load("test.map")
|
||||
actors.add({name="usufondo",x=11,y=9,o="r",gfx={x=0,y=0}})
|
||||
|
||||
actors.add({name="jailer",x=6,y=9,o="r",gfx={x=32,y=0}})
|
||||
actors.hero="jailer"
|
||||
|
||||
@@ -15,8 +15,15 @@ game={
|
||||
if not flags.usu1 then
|
||||
flags.usu1=true
|
||||
scene.start({
|
||||
function() actors.search("usufondo").path={pos=0,route='rrrruro'} end,
|
||||
function() balloon.show("HOLA\nQUE TAL?","usufondo",true) end
|
||||
function() actors.add({name="usufondo",x=16,y=8,o="d",gfx={x=0,y=0}}) scene.cont() end,
|
||||
function() wait.start(1) end,
|
||||
function() actors.search("usufondo").path={pos=0,route='dlllll'} end,
|
||||
function() balloon.show("HOY NO HAY JAIL!\n800 MEGAS!!","usufondo",true) end,
|
||||
function() actors.search("usufondo").path={pos=0,route='rrrrru'} end,
|
||||
function() wait.start(0.5) end,
|
||||
function() actors.remove("usufondo") scene.cont() end,
|
||||
function() wait.start(1) end,
|
||||
function() balloon.show("PAYASO...","jailer",true) end
|
||||
})
|
||||
end
|
||||
end
|
||||
@@ -40,13 +47,13 @@ game={
|
||||
|
||||
if not scene.script and hero and not hero.path and hero.dx+hero.dy==0 then
|
||||
if btn(KEY_DOWN) then
|
||||
hero.path={pos=0,route='d'}
|
||||
hero.path={pos=0,route='d',keys=true}
|
||||
elseif btn(KEY_UP) then
|
||||
hero.path={pos=0,route='u'}
|
||||
hero.path={pos=0,route='u',keys=true}
|
||||
elseif btn(KEY_LEFT) then
|
||||
hero.path={pos=0,route='l'}
|
||||
hero.path={pos=0,route='l',keys=true}
|
||||
elseif btn(KEY_RIGHT) then
|
||||
hero.path={pos=0,route='r'}
|
||||
hero.path={pos=0,route='r',keys=true}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
20
data/wait.lua
Normal file
20
data/wait.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
wait={
|
||||
start_time=0,
|
||||
total_time=0,
|
||||
old_update=nil,
|
||||
|
||||
start=function(seconds)
|
||||
wait.old_update=update
|
||||
update=wait.update
|
||||
wait.total_time=seconds
|
||||
wait.start_time=time()
|
||||
end,
|
||||
|
||||
update=function()
|
||||
wait.old_update()
|
||||
if wait.total_time <= time()-wait.start_time then
|
||||
update=wait.old_update
|
||||
scene.cont()
|
||||
end
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user