Rotation

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Rotation

Post 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?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Rotation

Post by Falco Girgis »

You wouldn't be storing every single little degree of rotation. Store maybe every 20-45 degrees.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Rotation

Post by ibly31 »

But I want it to have the best level of realism and be really smooth...
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Rotation

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Rotation

Post 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?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Rotation

Post 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.
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: Rotation

Post 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.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: Rotation

Post 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?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
Post Reply