Hey!
Has anyone got a suggestion for a sensible way of implementing a menu/selection system in Pico-8? I'm putting together a minigame collection, and trying to keep the code readable when everything has to share the same space (e.g. the init/update/draw loops) is proving a challenge!
Thanks y'all!
A statemachine and subfunctions.
Use one variable to set what state you are, and replace _update and _draw with just calls to UpdateGame, UpdateMenu, UpdatePause etc type functions.
How you would do it in c++ or something would be a switch/case, but iirc that isn't in LUA, so you need to do it with if/elseif.
Give each game its own init, update, draw. Make those methods on a table per game. Assign the current game's table object to a global variable called mode that is a reference to the current game . Call mode:init() in the global _init(), thereby calling the current game's init(), and so on.
Thanks! That's all really helpful - now I have a direction to work in!
Thanks for the (indirect) suggestion!
Because of you guys, I've added a Title/menu screen to my WIP (it'll come on the BBS soon, don't worry)!
[Please log in to post a comment]