This Is What It Sounds Like When Sprites Don’t Collide
Today I found myself lying on the couch feeling maudlin about sprite collision detection and resolution. It was not unlike speaking to my silent (and admittedly non-existent) therapist when I gave a small speech about how I wished I was smarter and knew how to things like collision. I fervently wished at that moment I was a mathematician or physicist or, damnit, just a better programmer! But no, I’m none of these things and so have been battling away with some collision stuff for PONGS for a good chunk of today.
I’m using Photonstorm’s awesome pixel perfect collision checking to find out if the ball is hitting certain falling shapes in a particular level of PONGS. That all works like a dream, but the problem is that the Photonstorm code doesn’t actually help you to resolve the collision. That is, you know that things hit each other, but not what to do about it in response. I’ve spent time looking at how Flixel resolves collisions between simple bounding boxes, but even that kind of zooms over my head. I get bits of it, then maybe some other bits, but by then the original bits are all gone again. Hopeless.
I solved one problem just before starting to write this, but the larger problem of the ball itself is proving super problematic. Sometimes it behaves itself. But sometimes it passes through solid objects, or bounces off them at entirely the wrong handle. And just when I’ve plugged one problem up, another springs loose. Most annoyingly, because PONGS is so simple, I don’t think I can afford to include any minigame in it that isn’t mostly “perfect” in its behaviour, so I need to get this right or abandon the idea. Gah.
So anyway, wish I was a physics whiz is all.