Hi! I'm toying around with Pico 8 for fun and relaxation on the side, where my primary pursuit is to develop games for the Nintendo Entertainment System in 6502 assembly.
It's fairly straightforward to implement coroutines in 6502 assembly and use them to represent state machines for entities (actors, etc.).
I was curious if it's common to use coroutines in Lua on Pico-8 for this purpose. I tried searching for "cocreate" in a couple of the featured games but no results came up.
Here's kinda what I was thinking.
sm=cocreate( function () --initialize entity/actor here print("step1") yield() print("step2") yield() print("step3") yield() --perform per-frame updates in here while(true) do print("inside loop") yield() end end) print("hi. welcome to the\ncoroutine tester.") coresume(sm) coresume(sm) coresume(sm) coresume(sm) coresume(sm) coresume(sm) coresume(sm) |
I think coroutines are keen and are probably underused in Pico-8 games. I wrote this article about using coroutines to drive animations:
https://docs.google.com/document/d/14HzJnqKdVtBjN2vN9-rZHLR3rlgwWwDym8ehzhKRqFo/edit?usp=sharing
More discussion on this thread: https://www.lexaloffle.com/bbs/?tid=3458
... also in the wiki: http://pico-8.wikia.com/wiki/Cocreate
[Please log in to post a comment]