Log In  
[ :: Read More :: ]

Cart #xpbd-0 | 2023-11-05 | Code ▽ | Embed ▽ | No License


This is a library to simulate physics using the eXtended Position Based Dynamics (XPBD) methodology.


  • page 0, library - 1368 tokens
  • page 1, demo - 698 tokens


It contains the following demos you can access with the left and right keys:

  • a single bead on a ring;
  • multiple beads on a ring;
  • a squishy square;
  • and an about page with particles.

The bead examples are ports of Matthias Muller's ten minute physics examples.


Include the first page for the library contents without any demo code.

#include xpbd.p8:0

function _init()
  local a = particle:new { pos = vec(64, 64) } }
  local b = particle:new { pos = vec(74, 64) } }
  sim = xpbd:new { 
    particles = { a, b },
    constraints = { distance_constraint:new { rest_length = 10, a, b } }

function _update()

function _draw()

See demos for how to setup.


  • I have not optimized the token count yet.
  • Collision resolution is not well worked out yet.


I'm curious if you could use XPBD to make a platformer that felt right. Maybe if it was stiff and used just a one step solver. I have serious doubts but would be fun to see.


Copyright (c) 2023 Shane Celis
Released under the MIT license


Many thanks to Matthias Muller and his collaborators for XPBD papers, code, examples, and videos that illucidate a refreshingly simple way to simulate physics.

P#136950 2023-11-05 09:05

[ :: Read More :: ]


  • page 1, library - 181 tokens
  • page 2, demo - 301 tokens

This cart is principally a library for interacting with the user in a query and response format using the keyboard.


You can include the library in your own cart by including only the first page:

#include keyboard-lemons.p8:1

The second page includes a demo with an old kids' game called lemons. The most salient feature is that user queries can be written straightfowardly:

answer = prompt("what's 2+2? ")

The magic—as it often does—lies in a little thing called coroutines.


Cart #keyboard_lemons-0 | 2023-10-26 | Code ▽ | Embed ▽ | No License

This is actually one of the first computer games I ever wrote, back then in gw-basic. It was a silly pen-and-paper game I had learned that I decided to try my hand at digitizing because I didn't know how to do anything graphical yet.


The keyboard.p8 library

  • handles backspace;

  • does not accrue string unless polled;

  • ergonomic prompt interaction code;

  • echo can be on or off;

  • allows you to substitute your own reader function;

  • return and 'p' will not pop up the pico-8 menu when being polled (unless enable_menu is set to true).


Many thanks to cabledragon for their inspiring mklib, a mouse and keyboard library, project. Their keyboard code is only 62 tokens too.

P#136428 2023-10-26 11:14

[ :: Read More :: ]

I've started to dip my toe into thinking about token minimization. Now I write most of my code in Emacs' pico8-mode, which I love since it presents the code in the same font as pico-8 so I don't feel I've strayed too far.

But I've been aching for a way to count tokens outside of pico8's editor. I found the p8tool which can do that and more, so I wrote this elisp function to make it accessible for me within Emacs.

(defun pico8-token-count (beginning end)
    "Calculate the number of pico-8 tokens in the file or region."
    (interactive "r")
    (let ((path (if (use-region-p)
                  (let ((temp-file (make-temp-file "token-count-" nil ".p8")))
                      (write-region "pico-8 cartridge // http://www.pico-8.com\nversion 5\n__lua__\n" nil temp-file)
                      (write-region beginning end temp-file t)
        (message (shell-command-to-string (concat "p8tool stats '" path "' | grep tokens | cut -d ' ' -f 3")))))

Here it is in action.

P#136058 2023-10-18 06:17

[ :: Read More :: ]

Cart #tinytest-0 | 2023-09-09 | Code ▽ | Embed ▽ | No License

This is the tinytest library for pico-8; it was inspired by the tinytest javascript library by Joe Walnes. It provides a basic unit test framework.

You can use it one of two ways: as a no frills library or as a singing, dancing cart.

Library Usage

You will enjoy colored text reports but otherwise no frills, but it's very flexible this way.

#include tinytest.p8

  demo_pass = function(t)
    t:ok(true, "hi")

  demo_fail = function(t)
    t:ok(false, "bye")

  demo_error = function(t)
    assert(false, "wtf")

  demo_misc  =
    t:ok(false, "bye2")
    assert(false, "wtf2")

Cart Usage

The cart comes with some images of bob from the incredibles in meme format and some audio sfx so you can hear the sweet sound of tests passing, failing, and erroring to make unit testing more fun.

In your cart, define my_tinytests:

-- yourcart.p8
my_tinytests = {
  demo_pass = function(t)
    t:ok(true, "yep")

Edit tinytest.p8's cart:

-- tinytest.p8
#include yourcart.p8

Load tinytest.p8 and on every run it will exercise your tests. Since it does an include, you don't have to reload either.


  • Add more bob meme images (only two currently)


Copyright (c) 2023 Shane Celis
Licensed under the MIT License

P#134089 2023-09-09 12:00 ( Edited 2023-09-10 05:50)

[ :: Read More :: ]

Cart #cardboard_toad-0 | 2023-02-28 | Code ▽ | Embed ▽ | No License

My six year old and I made this game for her upcoming birthday. She was inspired by paper mario and the idea of a pinata that ran away.

P#126445 2023-02-28 22:59