Rotating by an arbitrary angle is much more complex than 90 and 180 degree, because the - square! - pixel-grid does not match anymore. You'll also need to change (increase) the size of the rectangular sprite to hold the rotated version. You need to determine for each point in the new (rotated) sprite where it "comes from" in the old (original) sprite. If you want to get even more sophisticated, you should weigh the value from adjacent points so the picture becomes smoother and avoids raggedness due to aliasing (even though that works better for photos and at higher resolution than for painted, low-res sprites). Basic transformation:

For all points in the new sprite:

r_new = sqrt(x_new^2 + y_new^2)

phi_new = acos (x_new / r_new) (beware of the special case r_new=0, and also you'll need to treat each quadrant on its own because acos() is not unique across the full circle)

Calculate the original location (rho is the rotation angle):

phi_old = phi_new - rho

r_old = r_new

x_old = r_old * cos (phi_old)

y_old = r_old * sin (phi_old)

Get the color of pixel (x_old, y_old) in the old sprite. This is the color for pixel (x_new, y_new) in the rotated sprite.

Assume the old sprite is x_max wide and y_max high.

r_max = sqrt(x_max^2 + y_max^2)

To be on the save side, so the rotated picture always fits, make the new sprite r_max wide and r_max high.

All those formulas assume the origin (0,0) is in the center of the sprite!

Hope that gets you going!

Wolfgang

Composing music on the PocketPC! -

http://www.pdamusician.com