CeDSoFt's blog

vendredi, novembre 23, 2007

2D physics programming project

Why bringing physics simulation to a game / app ?
Just because it's the best way to have a real feeling of animation/interactions between objects and forces (gravity, explosions, etc.) in a game.

First step : Dynamics
What I've done with iSnake and its GameOver screen is to bring Dynamics problem to the iPhone. Basically, how the balls are moving/accelerating depending on the gravity (given by the accelerometer), their masses and the air friction.
To make the balls bouncing each other, I've added a collision detection algorithm with momentum conservation. (detection collision between ball was very simple : calculate the distance)

Next step : Bringing rotation after collision
The bouncing balls problem was quite simple but now, I have to compute rotation and its momentum on objects.
If you hit a rectangle object in a corner, it will not move straight but rotate. This is the next physic law about torques.
I need to experiment collision detection algorithm between simple shapes : rectangles and polygons.
Then, I'll have to calculate the rotation depending on the collision impact (torque).
Example : Contacts between rigid bodies

After that, there are some interesting stuff to add, all concern constraints : springs, rotation axis, etc.


Resources :
http://www.pfirth.co.uk/ (physics programming)
http://chrishecker.com (physics theories and programming)
http://www.myphysicslab.com/contact.html (physics theories and programming)
http://www.kloonigames.com/blog/games/crayon/ (crayon physics game : worth trying :-))


Examples of 2D rigid body collisions apps

2d Physics Demo v1.0



Crayon Physics




Libellés : , , , , , , ,

1 Comments:

  • Salut!

    Vraiment géniales tes applications, bravo!

    As tu l'intention de créer un jeu qui ressemble à "crayons" ? Ce jeu est tout simplement exceptionnel!

    Merci,

    PS : si tu as besoin d'aide pour les moments des forces et les torseurs de rotation, j'ai fait une prépa et une bonne grosse partie du programme traitait de cela. Je t'aiderais avec plaisir.

    Nils

    By Blogger Unknown, at 3:40 PM  

Enregistrer un commentaire

<< Home