Chipmunk2D Physics demo

Video

Download:
Chipmunk2DTest.pdx.zip (141.2 KB)

A quick toy I made using Chipmunk2D physics (https://chipmunk-physics.net)

No real plans to do more to this - I was just interested to see if I could get the physics library working on the Playdate.

13 Likes

Thats' really cool.

I was hoping someone would do some work on a physics engine so thank you for doing that. :slight_smile:

Right now it's all C right?

Yep, all C. I'm sure it's possible to make some nice Lua bindings, but that's beyond me at the moment.

Did you run this on device? What is FPS? I spent a lot of time working with physics on Lua and faced the impossibility of normal implementation due to the low performance of the device.

For example: everything is great in the simulator
but on the device after 5 objects the frame rate drops to 1 :frowning:
2

I tried the demo on my device. 22-25 fps. This is a great result!

1 Like

Yeah, I was impressed. Not sure if tweaking some settings could improve things further. (I didn't write the physics library - just made a few modifications to get it working on the Playdate.)

I've attached the source if anyone's curious, but it definitely shouldn't be used for anything important - much better to download the official Chipmunk2D library and make the few required changes to get it working on the Playdate.

Source only (567.2 KB)

1 Like

Missed this, but totally awesome!

I am confident that if drawing to the screen was optimised to only draw changed pixels each update then the increase in framerate would be huge. Drawing the whole screen every update automatically limits you to ~30fps and everything on top of that will decrease it further.

Hello! I'm doing exactly what you mentioned here, trying to get a (C only) playdate project up and running using the chipmunk physics library. I'm on Windows, attempting to use a visual studio solution. After a bit of trial and error I am now able to generate a visual studio solution that includes chipmunk source files, and my game's c source files. However I'm running into trouble compiling the project. first up, I get an error on line 561 of cpPolyline.c, it doesn't like the "struct Notch notch = {};" syntax. if I comment out the "{}" it compiles, but now I get a cryptic error about the command "setlocal" failing, without much into.

I'm wondering if you have any guidance on the changes you made to get your demo compiling?

well, as is usual the case, once I post about an issue I find a solution. I did have to change the syntax of line 561 as I mentioned above, but the "setlocal" issue was related to having the simulator open with an old build of my project .pdx opened when I attempted to make a new build. I think it fails because it can't delete the old build since it's in use by the simulator.

closing the simulator and building worked!

Did you ever get the chipmunk2d code running on the device? When I run it on the simulator it runs fine, but when I run it on the device it instantly crashes

I did get Chipmunk working on device, although honestly it was so long ago now I don't remember what issues I ran into and how I overcame them :blush: