Long Haul

February 25, 2011

So I worked pretty hard all yesterday and today and I made some good progress for the alpha tomorrow. Having given up on UIKit, I dug into Cocos2D and it was great and easy. Took a little while to figure out how exactly to then tie in Chipmunk, the physics engine, but it was exhilarating when I finally got that damn ball to fall down due to gravity!

However I ran into some major problems, mainly due to lack of any good documentation on both Cocos and Chipmunk but especially the latter (most references I found were for Box2D which is also supported but seems less apt for what I want to do). It’s very easy to set a global gravity in Chipmunk but setting gravitational pull independently for multiple objects is a bit more advanced.

To do this I need to create my own “Velocity Function” which the software than uses to do some Euler integration and get the result. However the documentation on this function is small at best. The function is described in the docs as follows:

void cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)

Default rigid body velocity integration function. Updates the velocity of the body using Euler integration.

From looking at the function I derived that it does essentially the following:


where v is the objects current velocity, f is the current force on the object and m is its mass. Now calculating the new gravity is easy enough yet when I use this functino nothing seems to happen. I need to play around with it a bit more. It’s possible that it is working and, due to how I’m setting my body masses or initial speeds, it just appears as if nothing’s moving.

Anyways excited for the Alpha Presentation today. Little worried about how it’ll work out with a video, as opposed to slides. I just gave each slide equal time so hopefully if I run out of time on one slide I can just make up for it later where I have nothing to talk about with a nice segue. My slides are pretty so that’s all that really matters, right? Let’s hope I can stay awake through it all after pulling an all nighter. But I’ve been sleeping pretty well recently so I’m not too worried.

Leave a Reply

Your email address will not be published. Required fields are marked *