Page 1 of 1
Rotation
Posted: Sun Jun 07, 2009 8:44 pm
by ibly31
Okay, so i'm making a game with sdl, and i need to rotate an image a ceartain number of degrees depending on which way the character is facing. I've heard of using SDL_gfx's rotozoom, and prerotating and storing the images in an array, but doesnt this take up an insanely large amount of space? 4 frames of animation * 6 characters * 360 degrees and not to mention all the leveldata and variables, wont this crash cuz of memory?
Re: Rotation
Posted: Sun Jun 07, 2009 11:27 pm
by Falco Girgis
You wouldn't be storing every single little degree of rotation. Store maybe every 20-45 degrees.
Re: Rotation
Posted: Mon Jun 08, 2009 6:36 am
by ibly31
But I want it to have the best level of realism and be really smooth...
Re: Rotation
Posted: Mon Jun 08, 2009 7:00 pm
by dandymcgee
ibly31 wrote:But I want it to have the best level of realism and be really smooth...
Then don't use SDL. Unfortunately, as great as it is, it has limitations just like every other API. I was trying to accomplish this very task recently which is why I started playing with OpenGL to begin with.
My recommendation would be the same as Falco's, don't store every single angle. 1/10th of them (36 frames) would look very realistic, but I'm betting even just 18 frames would still look excellent if the FPS was even slightly decent.
Re: Rotation
Posted: Tue Jun 09, 2009 6:28 pm
by ibly31
Okay, well I download "SDL_gfx" the library that has a rotozoomer. And I had to use a new tar.gz extracter program to do it. I have a big list of files, and I'm not entirely sure how to add it to my program... I have done SDL_ttf and SDL_image, but this has .c files so I dont really know. Can anyone help me?
Re: Rotation
Posted: Wed Jun 10, 2009 8:22 pm
by ibly31
Please answer, because I can't do anything with my game until i get this resolved...
EDIT:
Okay, so I'm looking at it, and it has all these weird file types, so I'm assuming this was made for linux or something... I have windows xp, does that mean I can't use it? Ugh, why does it have to be so complex, why can't it just have a lib and include directory?! sigh.
Re: Rotation
Posted: Wed Jun 10, 2009 10:09 pm
by andrew
Try this for Visual Studio:
Compiling SDL_gfx (2.0.17) on Visual Studio 2008 (VS9)
or this one for Code::Blocks:
Building SDL_gfx for Mingw under Windows
I haven't tried the Visual Studio one, but I was able to build the DLL with the Code::Blocks one. Hopefully you can get it working with this.
Re: Rotation
Posted: Thu Jun 11, 2009 6:51 pm
by ibly31
Thank you very much, that helped a lot. I have it working now. But I have a small problem... When SDL_gfx rotates the image, it must fill the unrotated part with Transparency pixels... and thus changing the bounding box... so it looks like my character is bumping up and down instead of rotating in place... is there any way of blitting an image by its center instead of top left corner?