Bounding Box Collision Detection

Teklectic · 52K views · 2012 · 2:51

Open on YouTube

Game programming & enginesAlgorithms & data structurestutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering 2D game collision questions, as a quick visual explanation of the AABB overlap test.

Recommended by 1 people across 1 different months, 2013 to 2018.

What it is

A short 2012 tutorial by Teklectic explaining axis-aligned bounding box collision detection from a C++/Allegro game programming perspective. The presenter walks through the overlap algorithm and suggests using graph paper to follow along.

What people said

Recommends Markus Hanel · 2018-07 · Stack Overflow · on “Javascript object collision”

The problem is that you return in the collision loop, resulting that only one object gets detected per movement. That would be fine if all movements were stopped / reversed but reversing only one direction allows the other to roam freely through anything else. A way to fix that would be to remove all returns in that function. Additionally watch that video " Bounding Box Collision Detection [this video] " to fix your algorithm because currently it ignores the width and height of your own avatar.

Cites Harry Lime · 2013-12 · Stack Overflow · on “C++ pulse counter”

I'm writing a shoot 'em up game on an Arduino and I'm using AABB collision detection - ref: Bounding Box Collision Detection [this video] My problem is with the time objects collide with each other, I'm currently using a basic trigger which is true for the duration two objects intersect. I think what I need is best described by the issue of pulse counting, where regardless of 'pulse length' (or intersection duration) only 1 count is detected: How may I implement this in C++? the function I'm currently using: bool CollisionTest( xPlayer, yPlayer, xAlien, yAlien, width, height) { if( ((xPlayer+width) >= xAlien) && (xPlayer <= (xAlien+width)) && ((yPlayer+height) >= yAlien) && (yPlayer <= (yAlien+he

Cites holdenweb · 2014-02 · Stack Overflow · on “How's this for collision detection?”

The problem of collision detection is a well-known one, so I thought rather than speculate I might search for a working algorithm using a well-known search engine. It turns out that good literature on rectangle overlap is less easy to come by than you might think. Before we move on to that, perhaps I can comment on your use of constructs like if x in range(target.get_x(),target.get_x()+target.get_width()): It is to Python's credit that such an obvious expression of your idea actually succeeds as intended. What you may not realize is that (in Python 2, anyway) each use of range() creates a list (in Python 3 it creates a generator and iterates over that instead; if you don't know what that mea