As I wont do it for you (maybe there is even something like this in the code archives):
The basic knowledge you need is how to rotate a point around another point in 2d space.
You have your rotation point - eg. the center of the grid, or the top left. And you have the local coordinate of the image. Eg. "-100,-100" regarding the center of the grid, or "0,0" with the rotation point being at the "0,0" coordinate of a 200x200 grid.
All you need to do is to calculate where the new "local coordinate" is when being rotated around the rotation center. All images in the grid share the same calculation (just different "local coordinates" are used - of course).
Edit: This is a piece of code I am using in my Dig-Framework (in the TVec2D-Class)
Method RotateAroundPoint:TVec2D(point:TVec2D, angle:Float)
local xnew:float = (x - point.x) * cos(angle) - (y - point.y) * sin(angle) + point.x
local ynew:float = (x - point.x) * sin(angle) + (y - point.y) * cos(angle) + point.y
x = xnew
y = ynew
return self
End Method
Think it should help if you think about what I wrote at the beginning of this post.
bye Ron
|