Kiwy64
A Pico8 inspired tool to make weird generative sketches.
2018-04-13
If you already saw the page about my Sketches in Pico8, you should already know that I love to mess around with code to create weird generative animations.
This is why I decided to experiment and try to make my own "fantasy console" like Pico8, but with a bit less constraint (even if I perfectly know that those Pico8's constraint are what makes Pico8 fun).
I started to learn how Pico8 works under the hood, and I discovered the world of Lua as a modular interpreted language to feed into a C++ program in order to code it in real time. So basically, the main C++ code is not too hard, and it's just a main that creates a window, setup all the inputs, and then tries to read a "cartridge" which is just a fancy Lua file. The fun part is that Lua could call certain functions that are defined and implemented in the cartridge interpreted in C++, and execute those in native code directly. This let me define some powerful macros and utility that the user can use with Lua.
Colors
To simplify the color handling, I decided to use a fixed palette just like Pico8, but with some more colors to chose from:
The Cartridge
This is what it looks like for the cartridge initialization where it maps all the function names in Lua to the correct C++ function:
Examples
With these function you can generate images like this one:
Or if you want to generate animations instead of static images you can simply use the update and draw function. For example this is a cartridge that play an animation:
And this is what an output looks like: