I'm working on this 2D space game, and I have to rotate images. So instead of manually making 16 different versions of the same thing and using spite sheets, I decided to try out "rotozoom" from the SDL_gfx library and save myself some time.
So far I hate the lack of documentation. But the worst part it's just that sometimes it works, sometimes it doesn't.
For example I have the following in my object constructor:
//create rotozoomed surfaces
itsSurface22 = rotozoomSurface (itsSurface0, -22, 1, 0);
itsSurface45 = rotozoomSurface (itsSurface0, -45, 1, 0);
itsSurface68 = rotozoomSurface (itsSurface0, -68, 1, 0);
itsSurface90 = rotozoomSurface (itsSurface0, -90, 1, 0);
itsSurface112 = rotozoomSurface (itsSurface0, -112, 1, 0);
itsSurface135 = rotozoomSurface (itsSurface0, -135, 1, 0);
itsSurface158 = rotozoomSurface (itsSurface0, -158, 1, 0);
itsSurface180 = rotozoomSurface (itsSurface0, -180, 1, 0);
itsSurface202 = rotozoomSurface (itsSurface0, -202, 1, 0);
itsSurface224 = rotozoomSurface (itsSurface0, -224, 1, 0);
itsSurface246 = rotozoomSurface (itsSurface0, -246, 1, 0);
itsSurface270 = rotozoomSurface (itsSurface0, -270, 1, 0);
itsSurface292 = rotozoomSurface (itsSurface0, -292, 1, 0);
itsSurface315 = rotozoomSurface (itsSurface0, -315, 1, 0);
itsSurface337 = rotozoomSurface (itsSurface0, -337, 1, 0);
And then I have a function for that object that returns a pointer to a surface which gets sent to the renderer:
SDL_Surface* cVessel :: getSuf()
{
/*
if( itsOrientation >= 349 && itsOrientation <= 11 )
return itsSurface0;
else if( itsOrientation >= 12 && itsOrientation <= 33 )
return itsSurface22;
else if( itsOrientation >= 34 && itsOrientation <= 56 )
return itsSurface45;
else if( itsOrientation >= 57 && itsOrientation <= 79 )
return itsSurface68;
else if( itsOrientation >= 80 && itsOrientation <= 101 )
return itsSurface90;
else if( itsOrientation >= 102 && itsOrientation <= 123 )
return itsSurface112;
else if( itsOrientation >= 124 && itsOrientation <= 146 )
return itsSurface135;
else if( itsOrientation >= 147 && itsOrientation <= 169 )
return itsSurface158;
else if( itsOrientation >= 170 && itsOrientation <= 191 )
return itsSurface180;
else if( itsOrientation >= 192 && itsOrientation <= 213 )
return itsSurface202;
else if( itsOrientation >= 214 && itsOrientation <= 235 )
return itsSurface224;
else if( itsOrientation >= 236 && itsOrientation <= 257 )
return itsSurface246;
else if( itsOrientation >= 258 && itsOrientation <= 281 )
return itsSurface270;
else if( itsOrientation >= 282 && itsOrientation <= 303 )
return itsSurface292;
else if( itsOrientation >= 304 && itsOrientation <= 326 )
return itsSurface315;
else
return itsSurface337;
*/
return itsSurface270;
}
What is happening is that the game crashes, and I ended up tracing it back to this file. I decided to manually return values. So far the only ones that work are itsSurface0, itsSurface90 and itsSurface270. All others crash the game.
You can probably understand my confusion since my code is identical for each of the surfaces...
I think I'll just go back to old fashioned sprite sheets, but I figured I'd post something here first maybe someone can help.
Alternatively, does anyone know of a program that can rotate and save images for you? Preferably something with an angle input/number of images and if it could create a sprite sheet that would be even better.