01-21-2023, 08:44 PM
And, if this was some type of space shooter, and one needed to *really* optimize collision checking for speed, here's the tricks I'd use:
1) only check the protruding points. They're going to collide before anything else does. With these stars, that'd just be the 8 end points on the peaks, and honestly, you could probably get away with just the 4 tips at each of the cardinal directions.
2) only check the protruding points in the direction we're traveling.
For example, if we're moving southwards (or down on the screen), there's not much need to check the topmost point to see if you crashed into something. (Caveat: If other things are moving across the screen as well, you might want to check those other protruding points for collisions.) If you can get by with just checking the point protruding in the direction you're traveling, then make use of that and you can reduce your collision checks down to a bare minimal, keeping FPS up as high as possible.
1) only check the protruding points. They're going to collide before anything else does. With these stars, that'd just be the 8 end points on the peaks, and honestly, you could probably get away with just the 4 tips at each of the cardinal directions.
2) only check the protruding points in the direction we're traveling.
For example, if we're moving southwards (or down on the screen), there's not much need to check the topmost point to see if you crashed into something. (Caveat: If other things are moving across the screen as well, you might want to check those other protruding points for collisions.) If you can get by with just checking the point protruding in the direction you're traveling, then make use of that and you can reduce your collision checks down to a bare minimal, keeping FPS up as high as possible.