summary refs log tree commit diff stats
path: root/scripts/common.lua
blob: d84d97dee741c46650093cf3ba871ad1df2ee1b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function waitForTick()
  return coroutine.yield()
end

function moveLeft(id, len, speed)
  local remaining = len / speed

  while (remaining > 0) do
    id:ponderable().vel.x = -speed
    remaining = remaining - waitForTick()
  end
end

function moveRight(id, len, speed)
  local remaining = len / speed

  while (remaining > 0) do
    id:ponderable().vel.x = speed
    remaining = remaining - waitForTick()
  end
end