Thanks for all the positive comments. The game is taking a while because things like drawing all the tiles and getting the enemies working well are very time consuming. I hope to get it out some time next year.
I don't know whether it would be commercial or free. Both have advantages. As the game compiles directly for windows, linux or gp2x (or in fact any SDL compatible system) it would be a shame to restrict it to just one system, although it would be good if it persuaded some people to get a gp2x. However if it were free then I could touch up the code base and release the source code, which is always nice.
@Dr. Ian: that looks like a lot of fun, is it all done in SDL? I think if you would release that code (especially the scrolling and streaming looks REALLY fluid a lot of people would benefit!
The only libs used are c standard libraries, SDL and SDL_Mixer.
I can understand how there can be problems with scrolling, as you mentioned, as SDL does some strange things in certain circumstances which can really trip you up and it doesn't tell you, only the framerate suffers.
Basically you must set the screen to be 320 by 240 and 16BPP as well as whatever flags you want (SDL_HWSURFACE | SDL_DOUBLEBUF). This is the screen format that the GP2X has, so if you don't set this, SDL will create a surface in memory with whatever settings you asked, and then downsample the image to the GP2X's screen format every frame. This doubles the rending time at least. You can also get around this by passing SDL_ANYFORMAT as a flag on other systems.
The next thing is to make sure to call SDL_DisplayFormat(SDL_Surface*) on every single surface you want to blit to the screen. This will adjust the surface to be the same format as the screen's surface. If you don't do this, it will down- or up-sample each surface on EVERY blit. You must also set the colour key before doing this, if you want to use one. For example:
Code:
SDL_Surface *temp = SDL_LoadBMP("hello.bmp");
SDL_SetColorKey(temp, SDL_SRCCOLORKEY, SDL_MapRGB(temp->format, 0xff, 0, 0xff));
hellosurf = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
If you don't do this the rendering time will be probably doubled again.
The last thing to know is about the bottlenecks in calling SDL_BlitSurface. Of course the speed is directly proportional to the area you are copying, but there is also a slightly large overhead in calling this function. When my rendering code draws in the panorama sky in the far background, instead of copying the sky only where it is needed, I just copy the whole sky over the screen before the rest is drawn on top. I do this because when there is a lot of sky visible (nowhere in the video I posted) the extra calls to SDL_BlitSurface mean it ends up a lot slower than just copying all of it in one call.
As for loading things off the SD card, I just made all the images the last BPP I could make them, and made sure to keep everything in memory once it is loaded, in the form of a linked list. As all the sprites are very small it doesn't use much memory, but even then a linked list like this can be optimized by counting accesses to each entry and sorting it quickly at each level change (or similar) then dropping the least used. The sounds are also loaded up during level change when each object spawns so that they don't interupt the music streaming off the card during gameplay.
I hope that explains enough. :wub: