src/ttyDisplay.lua has more or less the same interface as src/display.lua.
examples/tty.lua is almost identical to preciseWithMovingPlayer, but uses ttyDisplay.
examples/ttyNonblock.lua is similar, but sets stdin to non-blocking to support special keys (multi character escape sequences).
This seems to work pretty well, but needs a custom love.run. Ideally a demo like preciseWithMovingPlayer could load "ttyDisplay" instead of "display" and things would work with no (or few) other changes.
Using Love's APIs at all for ttyDisplay is questionable, but the goal is to allow display backend to be switched out without changing a bunch of other stuff, for example by using a command line switch when running a game. There doesn't seem to be any way around using Love's APIs directly since those APIs are only intended for end-users and not for library authors (anything destructive like love.update = func or love.keypressed = func is not really designed for library code), meaning the library can't simply encapsulate this functionality and abstract it away with its own API.
As far as I can tell, this means there's really no way to achieve an API like the display from rot.js, which uses stuff like requestAnimationFrame internally rather than requiring the client to call methods like display:update() and display:draw().
Anyway, TLDR, I'm wondering two things:
Has anyone already worked on a TTY display for rotLove?
How to handle display backends unrelated to Love, with respect to maintaining unified interface among backend APIs, given the challenges presented by Love's "unique" design?
I'd like to get rotLove working in a regular linux terminal. Has anyone tried this?
I threw a quick WIP together here: https://github.com/rotLua/rotLove/tree/ttydisplay
This seems to work pretty well, but needs a custom love.run. Ideally a demo like preciseWithMovingPlayer could load "ttyDisplay" instead of "display" and things would work with no (or few) other changes.
Using Love's APIs at all for ttyDisplay is questionable, but the goal is to allow display backend to be switched out without changing a bunch of other stuff, for example by using a command line switch when running a game. There doesn't seem to be any way around using Love's APIs directly since those APIs are only intended for end-users and not for library authors (anything destructive like
love.update = func
orlove.keypressed = func
is not really designed for library code), meaning the library can't simply encapsulate this functionality and abstract it away with its own API.As far as I can tell, this means there's really no way to achieve an API like the display from rot.js, which uses stuff like requestAnimationFrame internally rather than requiring the client to call methods like
display:update()
anddisplay:draw()
.Anyway, TLDR, I'm wondering two things: