Page 1 of 1

i need help with simple collision

Posted: Sat Jul 06, 2024 5:11 pm
by liar
so im trying to make a game where i need collisions. not the the really advanced polygon colliders needing a harvard student to figure out, like im just trying to detect if a ball is touching the paddle in a pong game. please help

Re: i need help with simple collision

Posted: Mon Jul 08, 2024 11:50 am
by togFox
You can search this forum or any dev blog for AABB collisions. In your case, pretend the ball is actually a square and the paddle is a rectangle and you'll get an idea, noting AABB assumes both objects are square-ish.

Re: i need help with simple collision

Posted: Mon Jul 08, 2024 1:34 pm
by dusoft
Or you can use love.physics module for collisions, but this is more difficult to start with.

Re: i need help with simple collision

Posted: Mon Jul 08, 2024 2:06 pm
by RNavega
You can safely approximate the shape of the ball with its bounding rectangle, and the same for the paddle(s).
This becomes a rectangle-to-rectangle collision which is a great thing to learn about (the AABB thing that TogFox is talking about).
Check out these links, in this order: