Using SDL_gfx's rotozoomSurface function to rotate a 38x58 sprite....naturally when it rotates it creates a new surface with a new size, and the rotation isn't going around the center point. I am actually having issues trying to figure out how to make it seem like its spinning around an axis...
Here is the image that I am using:
And here is the code that I have thus far:
#define ANGLE_STEPS 32
#define ANGLE_STEP (360 / ANGLE_STEPS)
...
int angle = 0;
SDL_Rect cpos;
cpos.x = cpos.y = 100;
...
// create chopper angled surfaces
for (int i = 0; i < ANGLE_STEPS; i++)
{
choppers[i] = rotozoomSurface(chopper, i * ANGLE_STEP, 1, 0);
}
...
// blit the currently requested angle
SDL_BlitSurface(choppers[angle], NULL, screen, &cpos);
...
// handle rotating the chopper
if (keystate[keys[LEFTKEY]])
{
angle = (angle + 1) & (ANGLE_STEPS - 1);
cpos.x = ?
cpos.y = ?
}
if (keystate[keys[RIGHTKEY]])
{
angle = (angle - 1) & (ANGLE_STEPS - 1);
cpos.x = ?
cpos.y = ?
}