diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-10 13:43:09 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-10 13:43:09 +0000 |
| commit | 11f3f88323a9f1b120b15a634538b05f1e5ccf3c (patch) | |
| tree | 2070209852da84e604e9767876f7a0ae46947694 | |
| parent | re-fix functions (diff) | |
| download | alive-11f3f88323a9f1b120b15a634538b05f1e5ccf3c.tar.gz alive-11f3f88323a9f1b120b15a634538b05f1e5ccf3c.zip | |
switch from luaposix to luasystem
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | init.moon | 25 |
2 files changed, 16 insertions, 13 deletions
@@ -13,7 +13,7 @@ text-based language and works without special editor support. - [LPeg][lpeg]: `luarocks install lpeg` - [osc][osc]: `luarocks install osc` - [socket][socket]: `luarocks install luasocket` (not required in love2d) -- [posix][posix]: `luarocks install luaposix` (not required in love2d) +- [system][system]: `luarocks install luasystem` (not required in love2d) ## running @@ -31,6 +31,6 @@ running in LÖVE adds the additional `gui` module. See [`lib/gui.moon`](lib/gui. [lfs]: https://keplerproject.github.io/luafilesystem/ [lpeg]: http://www.inf.puc-rio.br/~roberto/lpeg/ [osc]: https://github.com/lubyk/osc -[posix]: https://github.com/luaposix/luaposix +[system]: https://github.com/o-lim/luasystem [socket]: http://w3.impa.br/~diego/software/luasocket/ [love2d]: https://love2d.org/ @@ -1,5 +1,5 @@ -- run from CLI -import clock_gettime, nanosleep, CLOCK_MONOTONIC from require 'posix.time' +import monotime, sleep from require 'system' import Logger from require 'logger' import Registry from require 'registry' import Copilot from require 'copilot' @@ -18,13 +18,18 @@ for a in *arg Logger.init arguments.log delta = do - gettime = -> - spec = clock_gettime CLOCK_MONOTONIC - spec.tv_sec + spec.tv_nsec * 1e-9 - - local last, time + period = 1 / 60 + + local last -> - time = gettime! + if last + target, current = (last + period), monotime! + if current > target + L\warn 'Frame Skipped!' + else + sleep target - current + + time = monotime! with time - (last or time) last = time @@ -32,9 +37,7 @@ env = Registry! copilot = Copilot arguments[1], env while true - copilot\poll! - dt = delta! - env\update dt - assert nanosleep tv_sec: 0, tv_nsec: math.floor 1e9 / 60 + copilot\poll! + env\update dt |
