So one day, I decided to open the source of all my PICO-8 carts. I threw away a lot of not finished carts, yet I still ended up with a big number of them. And I not only wanted to make the carts downloadable but also to make them previewable in the browser. The typical way to do that with PICO-8 is the following:
> LOAD cart.p8.png
> EXPORT index.html
Then zip index.html
and index.js
, etc etc. But you know, even doing that with 20 carts will take quite some time.
And I knew BBS has a way to run carts without exporting them. So after a small research, I found a small library on Github, that allowed me to do just that, yet it was outdated for 3 years.
The perspective of just throwing a cart into the directory near your script to automatically make it playable was too good.
I talked a tiny bit with zep, the creator of PICO-8 console, and I got it working. So may I introduce you, pico-player, a tiny library, to magically load .png carts without exporting them. Now, creating something like my cart gallery is a piece of cake!
You just add a <div>
to your HTML code, throw a cart somewhere, and add a tiny drop of JS:
document.addEventListener("DOMContentLoaded", function(event) {
PicoPlayer('pico-container', 'cart.p8.png');
});
Note: the code must run on a server, or it will refuse to load the cart. Here is a simple server setup using python:
# If Python version is above is 3.X python3 -m http.server # If Python version is above is 2.X python -m SimpleHTTPServer
It should appear on
localhost:8000
Enjoy 🙂