lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> The only hurdle I had to jump was this: suddenly you realize you don't have
> a way to sequence events chronologically, because in LOVE, the only notion
> of time is "now." In the callbacks from the system each cycle, you're
> supposed to do a finite amount of work and get out, because the screen won't
> refresh until the next time you get the callback. So I didn't see any
> sustainable way to do, say, "start animation x, wait 10 seconds, then start
> animation y."
> To solve this, I built a little "actors" system using coroutines. The state
> of each game object is preserved by a coroutine, which yields after each
> step. Then, each update() and draw() callback just steps all the actors.
> This lets you sequence events by creating an actor that's just a "script",
> starting other actors, and waiting by just doing a coroutine.yield for a
> number of cycles.

This didn't really affect me, as I've got a lot of infrastructure for
that in the
aforementioned library that I basically brought over intact. It has some
possibly similar coroutine code that hasn't yet been incorporated into a
demo, and then a bunch of "streams" that are called at key points into which
you can inject events (one-shot or persistent), and a suite of helpers
to go with
these (e.g. sequencing like what you mentioned, timers, timelines, periodic

I'll probably put this up publicly (and MIT license) pretty soon,
though the demo
is nothing impressive. This has been the plan for a LOOONG time, but I've only
really gotten around to it lately. Part of the impetus behind this is
to force myself
to write documentation. :P

> Let me know if anyone is interested in that code; haven't
> placed it anywhere public yet.

I wouldn't mind seeing it. I bet you'd find a lot of interest on the
Löve forum, too.