Sprite Problem (bmp Bigger Than Screen ?)


darokin

Still Fresh
Joined
Jan 25, 2006
Messages
19
Age
41
Location
France - Reims
Website
yrkooon.free.fr
Hi,

I am coding a game for gp2x but I have a problem with one of my sprite.
For my sprite I load a picture wich contain all the frames of my sprite.
For example I have a ball.bmp wich contain the 4 frames of my ball wich make an animation.

And I do something like that to know wich rect of my surface I blit to the screen :
where spr is a structure to manage my sprites :

Code:
num = current_frame;

spr->rect.x = (spr->num * spr->w) % spr->full_w;
spr->rect.y = ((spr->num * spr->w) / spr->full_w) * spr->h;  

SDL_BlitSurface(spr->Surface, &spr->rect, screen, &spr->dest);

But the main character (a sheep) don't want to be shown. I thinks it's related with memory...
My prog don't freeze when I load the bmp but my sheep don't want to appear on screen. And if I try a SDL_SetColorKey (for transparency) on this surface, my prog freeze.
But the same thing WORKS PERFECTLY if I compile for windows instead !

I know my bmp is 24 bpp and my screen only 16 but it works with other sprite..
My sheep.bmp is 320 x 320...

I think it's a memory issue....
I couldn't load bmp bigger than the screen res ?
...I hope someone could help me by giving me more information
But I also hope I wont have to re-code the way I load my sprite because it's was quite boring to put all the frame in one image and was also easier for coding...

Sorry for my crappy english...
Thanks....
 
Just to add my sheep.bmp is big because it contain 8 frames to animate the sheep in 8 directions...wich make 64 frames...each frame is 32 x 32, so it can fit in 256 * 256 (actually it's 320 x 320 but the rest is empty)..
But if I take off the first and last line of each frame of my sprite, I could make my bmp become 256 * 240 with a 32 * 30 sprite and the bmp would be lower than the screen...
So there is a solution but I wan't to be sure that this is the problem...
 
What version of SDL are you using? Ie. Version numbers and who compiled it. There's more than a few different versions of SDL for the gp2x, and then some even with hardware acceleration, etc.
 
darokin posted on Feb 1 2006 at 03:19 PM said:
Just to add my sheep.bmp is big because it contain 8 frames to animate the sheep in 8 directions...wich make 64 frames...each frame is 32 x 32, so it can fit in 256 * 256 (actually it's 320 x 320 but the rest is empty)..
But if I take off the first and last line of each frame of my sprite, I could make my bmp become 256 * 240 with a 32 * 30 sprite and the bmp would be lower than the screen...
So there is a solution but I wan't to be sure that this is the problem...

I don't know for sure where is the problem but have a suggetion:

Precompute a table with coordinates for all sprite frames. This way you don't have to calculate them at every blit like in your code (there is divide too - avoid at every cost - it's expensive!) and for sure there will be much less space for an error.
 
Last edited by a moderator:
I compile via the devkitgp2x (arm-linux-g++)... It was a pack with basic SDL libs inside...
And I'm at work now so I can't tell you wich SDL version it is...
But now you asked..I don't use the same SDL libs to compile for windows...I don't have even think of this...
 
So...Squidge you think I should try to compile with another version (more recent) of the libs...
What would you purpose ?? To use the HW accelerated one ?? Another version ??
 
Humm...
The problem was inherent to my bmp file cauz I tried with another bmp of the same size and it worked great...
So now everything is cool and I can continue coding...
Sorry for the 'not so much a problem' and thank you all for your answers...
 
Back
Top