SDL_rotozoom or angle palet? How to set up rotozoom on Dev-C++

Started by
4 comments, last by KingSatchmo 18 years, 4 months ago
Hiya, I'm trying to write my first game which will be an asteroids knock-off... But I have run into a problem. If you've ever played asteroids you know that when you press the left and right arrow the spaceship rotates. Here in lies the problem... I have no earthly clue how to rotate my bitmap! I'm using SDL, of course, and currently I think I have 2 options. The first of which is rotozoom, which looks EXTREMELY complicated, and I was wondering if anyone had used this and if they have, could you give a recommendation? The second of which is having one of those palets that has the spaceship (a simple triangle) drawn at every angle (1 to 360) on it... that would suck to draw! I also don't like this method because it does not keep track of the angle, just the right bitmap image, so when I start implementing shooting I don't really think it would work, it would just shoot straight. So, I want to go with rotozoom but before I dive into this ominous looking library, does anyone have a better solution to my problem? Or some advice on rotozoom? [Edited by - KingSatchmo on November 29, 2005 3:48:01 PM]
Advertisement
The best way (IMHO) is to make an array of many SDL_Surface's to hold a pre-calculated rotated image of your ship. This way you won't need to suffer from real-time rotations or need to handdraw each ship. The more images you create, the finer precision of the final ship, but the more memory you use. For example:

SDL_Surface** CacheRotatedSprite(SDL_Surface* img, int num_angles){  SDL_Surface* ShipSurfaces[num_angles];  for(int a=0; a < 360; a += (360 / num_angles))  {    ShipSurfaces[a] = rotozoomSurface(img, a, 1, 1);  // No scaling; smoothening on  }  return ShipSurfaces;}


That was written without being tested, so you may need to tweak it a little. But hopefully the general idea is evident. ;)
I'm having trouble installing rotozoom into dev-C++... after downloading gfx, what do I do with what file?
Hey there.

You'll need to compile the source, and link to it. Don't ask me for specifics there; I've never compiled SDL_gfx before. To be honest, I don't even really know SDL. I just looked at the function prototype for rotozoomSurface() and took a decent guess, hehe. ;)

Anyways, if you can get SDL_gfx compiled, then you'd link to it, include the header in your project, and you'll then be able to access the rotozoomSurface() function. If you get stuck along the way, there's plenty of folks on the forums more knowlegable than I that will be more than happy to help you the rest of the way.

Good luck!
Quote:Original post by KingSatchmo
I'm having trouble installing rotozoom into dev-C++... after downloading gfx, what do I do with what file?


Since you are using DevCpp, it'd be a lot easier if you used the DevPak. Just download, install and you're ready to go! (Or at least theoretically [wink]) Thanks to Rob Loach for making it!
Quote:Original post by Drew_Benton
Quote:Original post by KingSatchmo
I'm having trouble installing rotozoom into dev-C++... after downloading gfx, what do I do with what file?


Since you are using DevCpp, it'd be a lot easier if you used the DevPak. Just download, install and you're ready to go! (Or at least theoretically [wink]) Thanks to Rob Loach for making it!


Thanks! That's just what I needed!!!

This topic is closed to new replies.

Advertisement