Circle Collisions in Games
From Derek Banas · · 54 sec

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.
If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.
Description
Detect the distance between the centers of two circles by comparing the two radii added together. If the distance is shorter, they're touching. That's the whole test. Nothing about edges. Nothing about corners.
The mistake is putting a box around a round thing. Bounding boxes overlap at the corners long before the circles do, and that gap is why every top down game with round characters uses circle collision: box hitboxes on circles means getting hit by things that visibly missed you.
Game Shorts #7. One mechanic per video, then the full game in long form.
#javascript #gamedev #coding #programming