i need help with simple collision

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
liar
Prole
Posts: 2
Joined: Sat Jul 06, 2024 5:07 pm

i need help with simple collision

Post 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
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: i need help with simple collision

Post 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.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: i need help with simple collision

Post by dusoft »

Or you can use love.physics module for collisions, but this is more difficult to start with.
RNavega
Party member
Posts: 385
Joined: Sun Aug 16, 2020 1:28 pm

Re: i need help with simple collision

Post 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:
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests