Log In  

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.

P#39044 2017-04-03 12:48 ( Edited 2017-04-04 16:33)

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)
P#39045 2017-04-03 13:04 ( Edited 2017-04-03 17:04)

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

P#39076 2017-04-04 12:32 ( Edited 2017-04-04 16:32)
P#39077 2017-04-04 12:33 ( Edited 2017-04-04 16:33)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 19:24:08 | 0.006s | Q:13