This question is not easily answered. There are 3 types of collision algorithms that may be written: Static, Semi-Dynamic, and Dynamic. Most of the discussions here were for Static collisions. Static collisions are when the algorithm assumes that the two objects are static, or not moving, even it they are actually moving. Semi-Dynamic collision algorithms account for object A moving, but assumes object B is static. Dynamic collision algorithms take into account that both objects are moving.

Static collision algorithms return only if a collision has occurred. The programmer only has the location of the objects to use for collision response. This is limiting, but sufficient for many games. Games like "Space Invaders" may be written using the algorithm. It is important to note that the static algorithms can have issues with small fast moving objects. Care must be taken to insure these objects cannot skip over each other in a single frame.

Semi-Dynamic collision algorithms return if a collision has occurred, The mathematical intersection point, the intersection time, the collision point (Where the two objects touch), and the collision normal. These algorithms take more time to execute, but return more information to allow for a wide variety of collision responses. This is the recommended algorithm I would use for most games. Games like "Break Out" may be written using this algorithm.

Dynamic collision algorithms return if a collision has occurred, the mathematical intersection point, the point where object A is at collision, the point where object B is at collision, the collision point, the collision normal for object A, and the collision normal for object B. This algorithm is the slowest to execute, but gives all the collision response details possible. This algorithm would be suitable to a "Break Out" like game that has multiple ball and if the balls collide they bounce off each other. Typically "Break Out" like game do not have the balls interacting with each other, therefore, the balls can occupy the same location with no response. This is not realistic, but how it is usually done.

The process for building the algorithms is fairly simple, but filled with a lot of repeating detail that make it cumbersome. The algorithms can be broken down into the following steps:

1) Identify the 2 objects to test for a collision

2) Create the collision area.

3) Test if the control point collides with any of the objects that make up the collision area. Divide and conquer decisions should be used to maximize efficiency.

The collision area is a composite of the 2 objects colliding. To create the collision object take object A and transcribe object A around object B. In the case of a circle colliding with an AABB, the collision area will have 4 circles at its corners, and 4 segments connecting the circles at their outer tangent points.

There is insufficient space in this blog give the algorithms in detail, but in the book "2D Collision Detection Algorithms for Game Programmers: Focus on Circle Collisions" will explain all 3 collision types for circles colliding with Points, Lines, Horizontal Lines, Vertical Lines, Rays, Segments, Circles, Ellipses, Axis Aligned Bounding Boxes (AABB), Object Oriented Bounding Boxes (OOBB), Capsules, and Polygons. I highly recommend this book.

You may also be interested in my other books also, they may be found at Amazon.com:

1) "2D Collision Detection for Game Programmers: Focus on Point Collisions"

2) "2D Collision Detection for Game Programmers: Focus on Circle Collisions"

3) "2D Collision Detection for Game Programmers: Focus on Ellipse Collisions"

In print soon:

4) "2D Collision Detection for Game Programmers: Focus on Axis Aligned Bounding Box (AABB) Collisions"

5) "2D Collision Detection for Game Programmers: Focus on Object Oriented Bounding Box (OOBB) Collisions"

6) "2D Collision Detection for Game Programmers: Focus on Capsule Collisions"

7) "2D Collision Detection for Game Programmers: Focus on Polygon Collisions"

8) "2D Collision Detection for Game Programmers: Focus on Collision Response"

Good luck with your game.

]]>Cheers! ]]>

Thank you very much! Hope the information will be useful for your portal readers!

I'm very excited because Iām doing c# online course now and Iād tried your tutorial as well and I managed to do it)

Have a good day!

Movement *= Movement

thoughout the steps but it changes to

Movement -= Movement

at the clean up which is the correct version ]]>

If you read the article to its end, you'll see that the code to make the chess board is under the heading: "Another noteworthy codesample".

If that doesn't make sense, just ask again :).

Kind regards - Jakob

]]>