Log In  

Cart #pico_physics-1 | 2019-12-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Z/X - previous/next demo
up - turn on/off aabb tree
down - reset simulation

Several physics demos I've written in pico-8. These follow from the work of Erin Catto (see http://twvideo01.ubm-us.net/o1/vault/gdc09/slides/04-GDC09_Catto_Erin_Solver.pdf)

The solver solves both inequality constraints (e.g. collisions) and equality constraints (e.g. joints).

I've reduced the framerate for web down to 30fps, but it works well at 60fps (in face the higher framerate is better for the solver).

Still issues to solve, e.g. jitter on resting contact, so I probably need to do a rewrite at some point.

I've added a couple more demos including mass-spring-damper systems

P#70781 2019-12-09 19:29 ( Edited 2019-12-10 17:58)

:: dw817

Astounding, @jimmi ! This kind of game creation method has always eluded me. The ability to link one object to another. Star for you.

I have a suggestion for the wiggle. Use a filter, that is if you received cached values of , "1, 3, 1, 3, 1, 3" then the actual value would be "2" where it does not wiggle.

P#70783 2019-12-09 19:36 ( Edited 2019-12-09 19:48)

Works very well indeed.

  • why x1L<x1R and x1L or x1R vs min(x1r,x1r) ?
  • ‘local’ize all your globals. This is significant cpu wise
  • is the hierarchical aabox worth it?
P#70787 2019-12-09 20:40
:: zep

This is so much fun!

P#70790 2019-12-09 21:12
:: jimmi

Hehe.. you are welcome 👍


  • min is probably better, I sometimes fall into patterns like this and then forget why
  • I wrote this code with closure based classes, the global you’re referring to are likely defined in an enclosing scope... there may be some globals I missed tho, will have a look.
  • without the tree you have a O(n^2) problem, probably fine with only a couple of objects, but performance will deteriorate quickly as you add bodies


  • what you are referring to would be damping, which unfortunately doesn’t work well with a constraint based solver. The jitter is because corrections applied to one part of the object can cause another part to collide and it ends up going back and forth.
P#70791 2019-12-09 21:26
:: dw817

Now that I'm messing with your code, I can see one thing that might give trouble to most Pico-8 users. You are declaring lowercase characters for variable names.

These cannot be typed in current Pico-8 and, @zep, perhaps there should not be a distinction ?

That is, any lowercase variables entered can also be addressed and accessed by uppercase, IE: "pi=3.14159" is the same as "PI=3.14159"

Currently there is a distinction and lowercase cannot be entered via the keyboard nor can it be searched for.

P#70792 2019-12-09 21:35 ( Edited 2019-12-09 21:52)
:: dw817

Here I recoded your program where all variables are normal (uppercase) and can both be edited and searched for:

Cart #bigokezizi-0 | 2019-12-09 | Code ▽ | Embed ▽ | No License

Here is a variation, where everything is super bouncy bouncy ! :)

Cart #bozudetedu-0 | 2019-12-09 | Code ▽ | Embed ▽ | No License

P#70793 2019-12-09 21:50 ( Edited 2019-12-09 21:59)

you need to demake Bridge Builder!

P#70855 2019-12-10 19:38
:: dw817

Either that or SUSHI KITTY, @jimmi.

Sushi kitty is an interesting game because although the cat is a circle, it's like a very soft ball that bends according to entering a type of Pachinko machine.

In these ledges and edges there are FISH for the cat. You drop the cat from the top and watch the charming animation of the cat slowly bouncing around, squishing on the sides like a big squishy ball to finally hit the bottom and a bonus.

You might actually have to see the game in play to understand what I am talking about. But as for your "physics" demos above, I think it would be perfect for a demake of SUSHI KITTY.

Can you do a squishy ball in Pico-8 ? I have a cart planned for January to show a way to make a ball APPEAR stretchy, but you're doing the real thing here.

P#70870 2019-12-11 01:37 ( Edited 2019-12-11 02:26)

holy smokes!

P#70890 2019-12-11 05:05

this is what i need, thank!

P#90524 2021-04-14 07:49


P#90715 2021-04-16 21:07

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-05-17 16:23:58 | 0.066s | Q:39