Lostcast 172: Pit Targeting Optimization

Overhead action game pits, target leading, particle optimization; it’s The Geoff Show!
Anemic Show notes
 A Wizard’s Lizard: Soul Thief
 Lostcast on Patreon
 You were played out by Hold, Please

Looking forward to falling into some pits!

The way you went around the pit detection is probably pretty sane. My initial thought when you mentioned the technical challenge would be to have some minimum width & height threshold with the intersection rectangle. Basically diff the bounding box overlap to get the intersection rectangle, and make a decision based on how much overlap there is if the player should fall in. I’d probably check if it’s 75% of the player’s size, and tweak it from there.
Stealing code from libgdx (as i always do), here’s their function for taking two rectangles and making an intersection rect:
static public boolean intersectRectangles (Rectangle rectangle1, Rectangle rectangle2, Rectangle intersection) { if (rectangle1.overlaps(rectangle2)) { intersection.x = Math.max(rectangle1.x, rectangle2.x); intersection.width = Math.min(rectangle1.x + rectangle1.width, rectangle2.x + rectangle2.width)  intersection.x; intersection.y = Math.max(rectangle1.y, rectangle2.y); intersection.height = Math.min(rectangle1.y + rectangle1.height, rectangle2.y + rectangle2.height)  intersection.y; return true; } return false; }

Since you guys off and on do a “drink cast”, found out there’s a brewery called “Lost Craft”, we have it in the fridge at work occasionally.

ooh that sounds perfect!