Hi, So i am trying to make a racing game. I have found a code/website (http://www.gamedev.net/reference/articles/article735.asp)that explains collision detection. However i cannot figure out how to implement this in my code. If anyone could help me to do this i would be very grateful. If you need me to post my code i will but its quite long.

Dani AI

Generated

The thread correctly starts with the basics but misses a few practical steps that make a racing game's collisions reliable and fast. cited a general collision article; is right that posting implementation details helps; 's language question matters; and 's suggestion to begin with simple shapes is a sensible starting point. Below are concrete, implementation-focused ideas that build on those points without repeating the formulas already mentioned.

A robust approach separates concerns: a fast broad phase to cull obvious non-collisions, then a precise narrow phase for candidate pairs. For broad-phase consider spatial partitioning (uniform grid or quadtree) to avoid O(n^2) pair checks. For narrow-phase use algorithms suited to the shape types chosen (convex polygons, compound shapes, etc.). For racing cars, compound shapes (a few primitives per vehicle) give a good balance of accuracy and speed. Fast-moving vehicles need continuous or swept tests to avoid tunneling; combine that with a fixed-timestep simulation to keep results deterministic and stable.

Collision response should be kept distinct from detection: compute contact points and resolve positions/velocities using impulses or positional correction, and iterate when multiple contacts occur. Instrument the game with debug drawing of collision bounds, collision normals, and per-frame contact logs to diagnose missed or spurious collisions. Clamp extreme velocities and keep world units sane (pick a consistent scale for physics).

For ready-made solutions or references: Box2D for 2D work and Bullet for 3D are mature engines, while algorithm references such as the Separating Axis Theorem and quadtree descriptions explain common narrow/broad-phase choices. Also read the fixed-timestep guidance for stable simulation. Thread-level details still missing here are language, 2D vs 3D, object representation, and the update/timing model — those determine the exact code path for integration.

Recommended Answers

All 3 Replies

To start things off, why not you post some logics about the code that you have implemented?

What programming language are you intending to use? decide then post in the forum for that programming language.

Hey, bounding-boxes is most simple collision detection method. What you didn't understood in that gamedev code exactly ?

Ok. If you want even MORE simple collision detection you can use this-
circle-circle collision method. Collision will be when: d <= r1 + r2 , here
d -> distance between circles centers.
r1, r2 - radius of first, and second circles respectively.
Assuming that you have images square-like, collision condition can be written as ((x1-x2)^2 + (y1-y2)^2)^0.5 <= 1/2*(Width1+Width2) here x1,x2,y1,y2 - coordinates of image centers.
Width1, Width2 - Width (or height) of those two square images.
Even when you have rectangles with edges approximatelly equal- you can still use this collision detection method, by setting Width1,Width constants to bigger rectangle edge, or something like (edge1+edge2)/2. So at first you can try this. When required you can switch to bounding boxes method.

Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.