Original Post
Bear with me here, as this is a bit of a long problem.
I have a 2D engine in C++, which im gonna port over to iso (sounds like a daft way of doing it, but theres a reason). One of the operations my sprites perform is to formate, in columns, squares and boars snouts. These formations are stored in a class, which takes the leaders position, and stores the position of all other members as an off-set of the leaders coordinates.
My problem arises from sprite rotation whilst in formation. I am currently using an equation as follows, which rotates the sprites through 90 degrees:
tempX = (sprite_X) - (X_point_of_rotation);
tempY = (sprite_Y) - (Y_point_of_rotation);
newX = (X_point_of_rotation) - tempY;
newY = (Y_point_of_rotation) - tempX;
where point of rotation is the leaders position and newX/Y is the new position of the sprite in question.
This algorithm is all well and good, but I need to be able to rotate through 45 degrees, thus allowing sprites to face 8 directions rather than 4. Frankly I haven''t a clue on how to do this, so any help would be grately appreciated. As a final note, I realise that I''m pushing my luck here, but please don''t tell me I need to do a FFT or dot product, as I''ll just stare at the screen and dribble! Code is good, maths is bad. My thanks in advance,
Gillan