SDL Bitmap Loading and Rotation Question

Started by
5 comments, last by Megafox 18 years, 3 months ago
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.
Advertisement
why do yo want to load so many bitmaps? i would rotate the image runtime.
i believe this is what you are looking for.

http://www.ferzkopp.net/Software/SDL_gfx-2.0/

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.
Rob Loach [Website] [Projects] [Contact]
:(

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.
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.
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.x = BITMAP_PLAYER_LOC_X + column;        frame.y = BITMAP_PLAYER_LOC_Y;	frame.h = BITMAP_PLAYER_H;	frame.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]

This topic is closed to new replies.

Advertisement