How to move the ball with constant velocity?

Official forum for the Chipmunk2D Physics Library.
Post Reply
ravi
Posts: 1
Joined: Mon Jan 18, 2010 8:40 am
Contact:

How to move the ball with constant velocity?

Post 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
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: How to move the ball with constant velocity?

Post by slembcke »

You didn't set the velocity update function in the code snippet above. Are you sure it was set somewhere else?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests