Sign in to follow this  

SDL Bitmap Loading and Rotation Question

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The reason I'm posting this here is because I could not find an satisfactory answer on the net. Every example I get only gives me half an answer or none at all or is so complex my brain turns to mush. So, I have this series of images of a spaceship that rotates from left to right in about 15 odd steps. My idea is so load these bitmap "parts" into a array and then rotate by 1 left or right when i press my left or right arrow key. ( by modifying the index to load the bitmap). I dont have a clear view on how to do this. I have seen classes created, seperate CPP and H files and various other methods. Which method is best and how can I go about doing something like this efficiently and effectively. And would my method of rotating be correct or is there a better way? Thanks for taking your time to read this.

Share this post


Link to post
Share on other sites
Yes, SDL_gfx is what you're looking for. Be warned though, that software rotation is VERY slow and shouldn't be done in realtime. Make sure you accomodate slow machines by caching all rotations you'll be doing.

Share this post


Link to post
Share on other sites
:(

i guess ill stratch that idea from my list hehe. although you say 'dont do it in real time'. while i havent used it yet, i was planning on it. but with that library, would i be able to create those frames of 'rotating' during a loading time or something instead of while i need it to rotate.

Share this post


Link to post
Share on other sites
I don't see what's wrong with using 16 frames of animation. It may look a bit chunky but most 2D games of the past were doing it the same way. Also the OP already has the artwork for the individual directions so it might be better to just have an array of SDL_Surfaces.

If you really want to rotate sprites then you might want to use OpenGL instead so you can draw the sprites with a bilinear filter and scale them at no cost.

Share this post


Link to post
Share on other sites
Yes at the moment my primary objective is to get my program working. I dont really need performance at the moment and because the bitmaps are only 30x30 i dont think it will slow down my computer in anycase.

But, as I am always learning I think I will give the Rotozoomer some attention as well.

Now to my original question, how do I go about coding something like this? Any suggestions or examples?

Ok this is what I have at the moment, but isnt working. The code executes since the console window prints "Executed".



SDL_Rect* frame = new SDL_Rect[15];

int i = 15;
int column = 0;

while (i--)
{
frame[i].x = BITMAP_PLAYER_LOC_X + column;
frame[i].y = BITMAP_PLAYER_LOC_Y;
frame[i].h = BITMAP_PLAYER_H;
frame[i].w = BITMAP_PLAYER_W;

column = column + 30;
}

int animate = 15;

while (animate--)
{
SDL_BlitSurface(g_Bitmap, &frame[animate], g_Window, &g_Player.screen_location);
printf("executed");
SDL_Delay(100);
}




[Edited by - Megafox on January 11, 2006 5:39:10 AM]

Share this post


Link to post
Share on other sites

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this