My dilemma now is that I want to check when two circles collides or how to write the algorithm that checks the collisions between rotated rectangles. On the engine that I'm working for Sonic The Hedgehog HD I need to rotate the sprites between 0° and 360° and I need also to work on rotated collisions but how? I tried to imagine 4 lines with the classic formula y=m*x+q, assign m converting the angle value with arctan but I can't realize how to write the code. But this isn't the only problem. If I decide to define a rectangle collision that won't rotate with the sprite (I'm assuming that the sprite is like a square and not a long/high rectangle) I can have other problems; the sprite can be rotated using any point of the space as center point but the collision will not rotate. Maybe some pictures can give more sense:
This is my sprite defined to the center of the space:
This is the same sprite with the same center, but with a rotation of 135°:
The sprite can be rotated without problems and without to rotate also the collision.
Now I take the same sprite but I move his center point:
But if I want to rotate the sprite by 135° from that point?
The result is weird. The sprite is rotate correctly, but the collision is fixed to that point.
Assuming to use my algorithm that checks the 4 angles from the first rect and the 4 angles from the second rect, if I rotate the collision, the detection will fail giving me wrong results. So I need to check the borders as a line defined from an equation, but how I can edit the equation if the lines will rotate using a specific point as center? And how I can check if a line cross another line when them has two limit points? I need to check pixel per pixel?