Making 2d game with chipmunk

Official forum for the Chipmunk2D Physics Library.

Making 2d game with chipmunk

Postby h2o » Wed Sep 12, 2007 1:49 am

I just recently found chipmunk, and got very interested.

I was planning to make a small "Liero"-like game but with a bit of physics involved. Now, I've just been playing around to try to get a feel for the library and I have one question which needs solving before I can move on.

Characters need to be able to move across the map, but how do I accomplish this?
I have managed to move them using cpBodyApplyForce, but then there are two problems:
1. Pressing a move key should make the character move x pixels and then stop, not give it x velocity. I solved this by checking the direction of the object and then applying a force in the other direction.

2. If there are slopes I don't want my characters to immediately slide down. Ideally moving up a slope should rotate the character but not slide them (some sliding is ok).

I am happy to receive any suggestions on implementations of this kind of game.
Posts: 1
Joined: Wed Sep 12, 2007 1:43 am

Re: Making 2d game with chipmunk

Postby supertommy » Fri Sep 14, 2007 2:46 pm

As for number 2 - have you tried modifying the friction property of your shapes? Maybe if you set the friction of both the characters and the ground to 1.0, you'll see a different result.
Posts: 56
Joined: Tue Sep 11, 2007 2:30 pm

Re: Making 2d game with chipmunk

Postby viridis » Wed Sep 26, 2007 2:41 pm

Just to know if you try (h2o) and if it is working ?
Posts: 2
Joined: Tue Aug 21, 2007 3:33 am

Re: Making 2d game with chipmunk

Postby AndyKorth » Mon Oct 29, 2007 9:54 pm

1) One suggestion is to make the move key give the character a certain velocity and then in your update method, cut that velocity down to a fraction of what it is. This will make things quickly come to a stop when you release the button. It'll be a little smoother than zeroing the velocity.

2) Increasing the friction should stop or slow the sliding. Tweak the moment of inertia to control the rotation.
User avatar
Site Admin
Posts: 36
Joined: Wed Aug 15, 2007 3:56 pm

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest