Chipmunk Playground

Share your projects and Chipmunk enhancements.

Chipmunk Playground

Postby maximile » Mon Aug 20, 2007 1:35 pm

Thought I'd talk about my ideas for an app/game, in case anyone else is already working on something similar.

The idea is Chipmunk Playground. You draw static and dynamic shapes in the editor, then press play and it starts simulating. Press stop and you're returned to edit mode (with everything in its original position). You can export to a Quicktime movie or whatever.

I had a few thoughts about the implementation. I think that segments would be reserved for static bodies. I'd introduce the concept of "materials", where every body is assigned a material. Each material controls surface friction, elasticity, and density. Materials would also control what happens with collisions, e.g. collisions between material 1 and material 1 are ignored, but collisions between material 1 and material 2 take place.

In the future, I'd like to add a third option - collisions between two materials trigger a script. That way, you could make a pretty cool game-making toy. You could make a breakout game by:

  • Drawing a box around the arena using segments. Assign material 1 to the bottom one.
  • Drawing and duplicating rectangles for the bricks, and making them all material 2.
  • Drawing a rectangle for the paddle, and setting its x position to be controlled by the mouse x position.
  • Drawing a circle for the ball. Give it an initial velocity and give it material 3.
  • Writing scripts that perform all the various actions you'd expect based on the collisions given.

I dunno what the scripting language would be. Lua, maybe? Anyway, then you'd test it, tweak it, and eventually choose "Create Standalone Application" from the File menu.

But that's all in the future. To start with, I'd be pretty happy if I could just draw a few (hundred) circles, a few lines for them to bounce off, turn up the gravity, hit play and watch them bounce.

If anyone's interested, I plan to make it a Core Data Document-Based application. The interface will all be Cocoa, but the things that happen in the edit/play window will be C and OpenGL. I've already written quite a lot of code for editing 2D shapes for a previous project, which should speed things up a bit.

So anyway, that's my rambling post about my idea. Hopefully I'll have something done within a week or so to show off. We'll see.
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: Chipmunk Playground

Postby slembcke » Tue Aug 21, 2007 2:44 am

I've been thinking about creating something like this for a while. Should be interesting to see what you come up with.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Chipmunk Playground

Postby viridis » Tue Aug 21, 2007 3:48 am

Your idea remember me the "Crayon Physics" game.
You must resolve "puzzles" by adding object to the scene. Objects are added by sketching them.
http://www.kloonigames.com/blog/games/crayon/
viridis
 
Posts: 2
Joined: Tue Aug 21, 2007 3:33 am

Re: Chipmunk Playground

Postby viblo » Tue Aug 21, 2007 3:50 pm

Ive been thinking about something like crayon physics for a while. Ive written a freehand-polygon-drawing script and a couple of ideas to make something different from crayon physics, but got distracted by how fun freehand-polygon-drawing + physcis is, how to draw freehand drawings like in crayon physics with opengl (or pygame/sdl) in python and how you divide a concave polygon into many convex ones :)
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm

Re: Chipmunk Playground

Postby maximile » Tue Aug 28, 2007 6:11 pm

Ok, well, it took me a while to get my head round Core Data, but now I sort of understand it I'm amazed by the functionality it gives.

Here's a video of the progress so far: http://www.youtube.com/watch?v=6EeJB9Qc9Fg

You can have a binary or source to play with if you really want (PM/e-mail me), but this is as far as I plan to take this version - the code is ugly and the data model needs a hefty update. And obviously, it needs a much better way to edit it. And support for more shapes and materials and so on and so on. So I'm going to start from scratch.

This is all going on inside Objective-C. Most of it works fine, but I had to write a C-style function to handle the callback for displaying the shapes. And since I can't seem to call any Objective-C methods from inside that function, that's annoying. Does anyone here know how to deal with this? I'm talking about this bit:
Code: Select all
cpSpaceHashEach(space->activeShapes, &drawObject, NULL);

Thanks!

EDIT: Oh, and another thing: I never asked if it was okay to call it Chipmunk Playground. Is it okay? If not, I don't mind calling it something else.
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: Chipmunk Playground

Postby slembcke » Wed Aug 29, 2007 12:19 pm

maximile wrote:Oh, and another thing: I never asked if it was okay to call it Chipmunk Playground. Is it okay? If not, I don't mind calling it something else.


Yeah, why wouldn't it be? Chipmunk's under a pretty liberal license. If I said no, you could just branch the source and call it Maximile's Physics Library. :p
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Chipmunk Playground

Postby sporkstorms » Wed Jun 11, 2008 8:28 pm

maximile,

This is a wonderful idea, and I'd be very interested to learn of any updates.

Back in the day (OS 7 or 8?) there was a similar program (it pains me, but i can't remember the name). It was a 2D physics simulator.
* You'd draw circles, squares, lines, polygons.
* You could assign properties to them: initial velocity, mass, friction coefficients, etc.
* You could draw connectors between shapes: ropes, springs, joints
Then you run the simulation and watch it go.

I'm extremely interested in finding something like this again. I'm a science teacher now and think it would be a great tool for students to use for constructing virtual mini-experiments.

Let me know if you've worked any more on your playground app, or if you'd care to share the code so that I might possibly work on extending it (when/if I have time).
- mark
sporkstorms
 
Posts: 3
Joined: Wed Jun 11, 2008 8:21 pm

Re: Chipmunk Playground

Postby maximile » Thu Jun 12, 2008 4:19 am

I don't remember anything similar for the Mac, but there could well have been. I do remember Interactive Physics on Windows, which I used to mess around with for ages in my school library.

As for the status of the project, you can currently do pretty much all of what you listed except ropes and convex polygons. The main problem is the interface, which is not great. You can drag things around, but to resize or rotate things you have to type in values into text fields. It's already fun to play with; building little vehicles and watching them try to get over terrain.

I'd love to see it used in education, but I'm not sure how accurate it is.

Anyway, I've been very busy recently working on a short film for my course. That has to be handed in tomorrow, so after that I'll get to work on preparing a somewhat stable build. I don't mind releasing the source code either (though I would like to release the app as shareware sometime), but it's not very nice at the moment. I intend to rewrite it soonish. Until then, you can see some old videos here: http://www.youtube.com/results?search_query=chipmunk+playground&search_type=&aq=f
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: Chipmunk Playground

Postby sporkstorms » Fri Jun 13, 2008 12:34 am

Thanks for the update.
Keep us posted on any news. That's a great project you've started.

- Mark
sporkstorms
 
Posts: 3
Joined: Wed Jun 11, 2008 8:21 pm


Return to Community Creations

Who is online

Users browsing this forum: No registered users and 0 guests

cron