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 : , , , , , , ,

vendredi, novembre 16, 2007

Multiple objects collision detection algorithm (in iSnake)

I've just added a multiples objects collision detection (bouncing balls) to my current iPhone app development : iSnake.

It's another step to my platform game development, but now I have most of the parts of a pool game...

You can download the current version of this game on my test repository (Installer.app) : prog.cedsoft.free.fr

Je viens d'ajouter un algorithme pour la detection d'objets multiples (balles rebondissantes) au jeu iSnake pour iPhone.

C'est un autre pas vers le développement de mon jeu de plateforme, mais là j'ai pas mal d'éléments pour commencer un jeu de billard...

Vous pouvez télécharger la version actuelle de ce jeu sur mon dépôt de test (Installer.app) : prog.cedsoft.free.fr

More about collision detection and physics programming :


Video :


Libellés : , , , , , ,