Page 1 of 1

Best practice for game movement

Posted: Fri Jun 13, 2014 8:09 am
by HunterZolomon
Hi all, I just joined and I'm new here and to Chipmunk. I'm currently working on a little game project where I want to use Chipmunk.js + Pixi.js for a WebGL rendered javascript game. So far it's working great, Chipmunk has been very easy to implement. I have a few noob questions though:

1. Is there any best practice when it comes to movement in games? I'm not using gravity but I need to have some kind of friction or dampening to the players character in the Chipmunk space. What I need to do is apply a motion vector (with speed constraints) to the player body and have that fall off once the user lets go of a directional pad. I can think of a few ways, but this is the first time I use a proper physics engine so I'd appreciate if anyone could give me any pointers to what is best practice when atttempting this kind of functionality. Applyforce with some kind of deceleration?

2. I'm building the game world with tiles constructed from segments. Sometimes the segments connect from tile to tile to form one long line and when the body is touching that line while moving it will sometimes "bump" where the segments connect. I know this is a common physics engine issue, but is there a good workaround in Chipmunk?
I currently use the segment radius function and it helps quite a bit. But since you need to compensate for the radius padding the solution doesn't feel very elegant. Neither do I want to go through the world (it's quite large) and replace the segments that align with one segment since performance tweaks will be a bit more tricky when segments are shared between tiles. Any thoughts?

Lastly, thank you for a great physics engine! Even though I'm just getting into Chipmunk it feels like a solid choice.

Re: Best practice for game movement

Posted: Tue Jul 01, 2014 8:20 am
by maximile
Surface velocity tends to be handy for player movement. You can see how we did it in a small project here:

https://github.com/maximile/Your-Story/ ... haracter.m

(Look at playerUpdateVelocity. In action: https://www.youtube.com/watch?v=AHaOfBp-raY )

Unfortunately, I think merging the collision shapes is the only way to go for eliminating the bumps. This might be sorted in a future release, see here: http://howlingmoonsoftware.com/wordpres ... pmunk-6-2/

Re: Best practice for game movement

Posted: Wed Jul 02, 2014 6:42 pm
by HunterZolomon
Most appreciated, thanks! I'll have a look at your links and see what I can discover :)