Post

PICO-8 Games with LUA

PICO-8 Games with LUA

PICO-8 Games with LUA

The PICO-8

In the game Celeste there is a minigame in which you play a retro-style version of the game on a little console called PICO-8. It turns out that the original version of Celeste was actually made for the real PICO-8 which is a virtual machine / game engine that resembles a retro game console with a command-line interface / terminal that runs Lua code to create simple pixel-art games.

The benefits are that PICO-8 runs across many systems eg.Windows, Mac, Linux and on the web. And that you can export PICO-8 games as “cartridges” which are actually .png images that contain all the data for your game, in the .p8.png format

There are significant limitations, namely a 16-colour palette, 128x128 pixel resolution, and a hard cap of 8192 tokens for your code, but these limitations create simplicity and form part of the benefits listed above. You can read the FAQ for PICO-8 here

[!IMPORTANT] In order to create, export, and distribute.p8.png game cartridges, or standalone HTML5 files for PICO-8 you need to buy a license

Playing PICO-8 Games

You can access and play any game in the PICO-8 repository here, including the original version of Celeste which can be played here

Creating PICO-8 Games

Creating PICO-8 Games without a License

Users without a license can write and run games at the using the free PICO-8 Education Edition which can be accessed here. This is a feature-complete version of the PICO-8 with the ability to write, load, save and run Lua code for PICO-8 games. It is missing the functionality to export to .p8.png or .js / .html but it allows you to save files as .p8 files. An example .p8.png file can be found here

Creating PICO-8 Games with a License

For a licensed user you would write or load Lua code into PICO-8 and either export to .p8.png or export to an entirely self contained project that contains files in a structure that resembles the directory tree below. You would be able to host this on a static site eg. GitHub pages, as long as you give correct attribution for pico8.wasm. Additionally you could also use this to play the game entirely locally. You can read more about the export process here

1
2
3
4
5
6
mygame_export/
├── mygame.html
├── cart.js
├── pico8.js
├── pico8.wasm
└── index.html

Embedding PICO-8 Games

You can embed games that have been published to the lexaloffle site within your own site via an <iframe>. You can find the “embed” button at the bottom of any game on lexaloffle

1
<iframe src="https://www.lexaloffle.com/bbs/widget.php?pid=53976" allowfullscreen width="621" height="513" style="border:none; overflow:hidden"></iframe>

You can also add the cartridge image within a clickable link with code similar to the <a> tag below

1
<a href="http://www.lexaloffle.com/bbs/?pid=12030" target="_blank"><img src="http://www.lexaloffle.com/bbs/cposts/4/40278.p8.png" title="⭐135─Tempest - Survive the harsh elements through salvaging nature. 🎮by impbox" alt="image"></a>
This post is licensed under CC BY 4.0 by the author.