- [WIP] Actors behaviour. Switching computer
This commit is contained in:
@@ -2,6 +2,7 @@ actors={
|
|||||||
list={},
|
list={},
|
||||||
|
|
||||||
add=function(actor)
|
add=function(actor)
|
||||||
|
actor.dx,actor.dy=0,0
|
||||||
table.insert(actors.list, actor)
|
table.insert(actors.list, actor)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -12,6 +13,44 @@ actors={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
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
|
||||||
|
if v.path.pos > #v.path.route then
|
||||||
|
v.path=nil
|
||||||
|
else
|
||||||
|
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=-8
|
||||||
|
elseif step=='d' then
|
||||||
|
--check collision!
|
||||||
|
v.y=v.y+1
|
||||||
|
v.dy=8
|
||||||
|
elseif step=='l' then
|
||||||
|
--check collision!
|
||||||
|
v.x=v.x-1
|
||||||
|
v.dx=-8
|
||||||
|
elseif step=='r' then
|
||||||
|
--check collision!
|
||||||
|
v.x=v.x+1
|
||||||
|
v.dx=8
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if v.dx > 0 then
|
||||||
|
v.dx=v.dx-2
|
||||||
|
elseif v.dx < 0 then
|
||||||
|
v.dx=v.dx+2
|
||||||
|
elseif v.dy > 0 then
|
||||||
|
v.dy=v.dy-2
|
||||||
|
elseif v.dy < 0 then
|
||||||
|
v.dy=v.dy+2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user