- implementat actors.remove()
- FIX: El moviment per tecles residual no ha de influir en la escena
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user