My next project is likely going to need to rotate sprites, so I've been looking at the various methods posted on the bbs. Something I'm wondering about while I've been looking at everyone's examples is, how does one approach collision detection for when a sprite is rotated?
I'm currently capable of AABB and bitmasking per row of pixels, but it seems I'm going to have to write some new methods to integrate either of these into a rotation algorithm, and I'm not sure where to start. I'd appreciate any links to any carts or non-p8 articles or anything, really!
CPU is also a concern for me, as I think I'm going to need a lot of it dedicated to drawing the backgrounds I need which would be rendered via something like spellcaster's rle library.
Thanks in advance! :)
The easiest/laziest way to do it is the YOLO approach: redraw all your sprites so that they have a more or less circular shape. Then you can use the very fast circle collision no matter their rotation angle!
Next possible level is "just let it not be perfect": rotate the sprites, but keep using AABB for them as collisions. It will not be perfect, but it can be good enough, especially on a fast-paced game with small sprites.
Next level is approaching each of your sprites with a polygon, and using such polygon for collision detection. This can get hairy really quickly. Calculating collisions between two moving polygons (especially if both of them can move fast relative to each other in a single frame) can get very tricky, very fast.
@kikito I don't think I can get away with circular-like sprites, but I had never considered using a radius for collision. Thank you for that!
Regarding the polygons, is that because of the number of calculations involved? (ie, to check one position of one actor between frames, let alone multiple positions and multiple actors?)
Looks like I'm going to have to figure out a rectangular AABB system that's "good enough", maybe using multiple hitboxes. Anyway, thank you, I appreciate your insight!
@VgBlade I couldn't find much on the technical side, but I was under the impression it used bit masks. However, I did find out it only does a collision check every other frame, which kind of blew my mind, and I now I know how the -1 bug actually works! I found this big list of them, I think I've only encountered less than a dozen of these in my lifetime!
[Please log in to post a comment]