Without video it's hard to be sure (and I'm not really sure what's going on in your code with player.x.x), but from your description it sounds like you're rotating around the wrong center.
When you apply a rotation, it *always* rotates around the origin (0, 0). So if you want to rotate around some other point, you need to translate to the origin, do your rotation, and translate back.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | vec2 p = ...
vec2 center = ...
// Translate the center of rotation to the origin. (p - center)
float x = p.x - center.x;
float y = p.y - center.y;
// Do the rotation
float angle = ...
float ct = cosf(angle);
float st = sinf(angle);
vec2 new_p;
new_p.x = (x * ct) + (y * -st);
new_p.y = (x * st) + (y * ct);
// Translate back. (p + center);
new_p += center;
|
(If you do a lot of these, you'll want to bake them into a matrix instead. But it's the same process.)
What you are actually rotating is not the point, but the *vector* to that point from the center of rotation.