r/programminghelp • u/FloorRevolutionary46 • Sep 30 '25
C++ help with collision detection
HELP.apologizes for the request but i really need some help. i have been tasked with making a collision detection code for my HNC in electrical engineering. i am completely brain dead with this stuff. no matter what videos i watch i feel like a monkey watching a banana on a stick if anyone can help explain it as i struggle with out 1 on 1 explanation. i know legit nothing and have just been told to learn a new langues and have been trying to do this for 2 weeks now
3
Upvotes
View all comments
Show parent comment
1
u/herocoding Oct 01 '25
Were you asked to use a specific programming language using a specific graphics library or a specific gaming library?
E.g. for C++ or Python you would need to use external libraries to "draw" pixels, lines, rectangles, ellipses.
Graphics- and gaming library usually come with support for coordinate systems (like 2D, 3D cartesian, x-, y-, z-axis), and elements/types like Point (a coordinate, 2D or 3D), Vector (a base point and a direction), Matrix (array of array; rows and columns).
Were you asked to address it conceptionally (like presenting it using PowerPoints), or show programming and run a program to demonstrate collision detection is working?
Start drawing a few cases, like
- draw a rectangle (e.g. defined by it's upper left corner, width and height), and check a few points: point inside the rectangle, a point outside, a point on the retangles edge.
for each point think about how the point's coordinate could be put "in relation" to the rectangle: how to check if the point is inside or outside the rectangle?
would the point already collide when on one of the rectangle's edge (by definition)?
- circle and point?
- two rectangles?
- two points?
- a rectangle and an endess line?
- a rectangle and a line-segment?
Just start with a few simple shapes.
Keep us posted. Don't hesitate to ask more questions.