Discord
Login
Community
DARK THEME

Collision detection problem

So I am on a journey of trying to recreate classical games, like pong, snake, galaga, ex. And I've started with pong.

I've ran into a problem, the collsion detection for the ball and paddle is rectangle(AABB) collisions.

The problem is that the ball collides with only the middle and the top, while completly ignoring the bottom.

link to my code - https://microstudio.dev/i/MrBoi/newpong/

Thanks in advance :D

This is the code that I usually use for AABB collisions:

AABB = function(a,b)
  if abs(a.x-b.x)<(a.width+b.width)/2 and
    abs(a.y-b.y)<(a.height+b.height)/2 then
    return true
  else
    return false
  end
end

And it seems to fix your problem?

This does seem to fix my isue!

Thanks!

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community