Page 1 of 1

How to move the ball with constant velocity?

Posted: Mon Jan 18, 2010 9:05 am
by ravi
Hi all,
I have just started learning Chipmunk. I have created ball body as shown bellow,
cpBody *body = cpBodyNew( _Ball_Weight_ , INFINITY);
cpSpaceAddBody(space, body);
newBall->shape = cpCircleShapeNew(body, redious, cpvzero);
newBall->shape ->e = 1.0f; newBall->shape ->u = 0.0f;
newBall->shape->data=newBallSprite;
cpSpaceAddShape(space, newBall->shape );
newBall->shape ->collision_type = kBall;
newBall->stage=bSlow;
newBall->velocity=_Ball_Initial_Velocity_;
I don't wants to decrease the velocity when this body collide with other body. but its velocity decrease when collide with bellow define body.
cpBody *body = cpBodyNew(10,INFINITY);
cpSpaceAddBody(space, body);
newpot->shape = cpPolyShapeNew(body, num, verts, cpvzero);
newpot->shape->e = 0.0f; newpot->shape->u = 0.0f;
newpot->shape->data = newpotSprite;
cpSpaceAddShape(space, newpot->shape);
newpot->shape->collision_type = kPot;

In my space object I set gravity to zero. but as I only wants to move the kPot type object down , I updating kPot the velocity in step func'n which call continuously as shown bellow.

damping = cpfpow(1.0f/1.0f, -1/30);
cpBodyUpdateVelocity(shape->body, _Gravity_For_Small_Brick_, damping, 0.01);

Please Help me in solving above issue.

Thanks

Re: How to move the ball with constant velocity?

Posted: Mon Jan 18, 2010 9:37 am
by slembcke
You didn't set the velocity update function in the code snippet above. Are you sure it was set somewhere else?