Helo
I have a function in my program that will copy a “piece” of a
surface, to another surface. I dont know if im not using SDL_BlitSurface the
correct way for copying off screen surfaces, or if its a C++ problem (it
doesnt seem to be), or what.
As i dont have yet a good knowlage of debugging, i used a kind of “log
file” where i put the values of some variables. That way i found the
error… but i dont know how to solve it.
Here is my function, commented (without the log file stuff)
int CSprite::load(CSpriteBase *base, SDL_Surface *screen)
{
cBase = base; // checked, and not NULL
if (cBase->aBuilt) // checked and its “1” (built)
{
SDL_Rect src;
src.y = cBase->Anim[cFrame].aY; // checked, aY = 300;
src.x = cBase->Anim[cFrame].aX; // checked, aX = 250;
src.w = cBase->aW; // checked, aW = 34;
src.h = cBase->aH; // checked, aH = 96;
// OK, cBase->frame is a BMP with some frames for my sprite.
// its checked, and it loads the file perfectly, and shows the
cFrame
// current frame on the screen.
// So… now I want to put the piece of that frame (first
frame)
// in BackReplace surface. As it will be the first thing i
will “replace”.
SDL_BlitSurface(cBase->frame, &src, BackReplace, NULL);
if (BackReplace == NULL)
return -1;
// and as i check here, BackReplace is not been loaded : /
cScreen = screen;
}
return 0;
}
I also checked almost everything on my code… it seems to be ok,
everthing
works fine! BUT, the only problem is that BackReplace wont get loaded.
I Also use BackReplace on some other functions to replace a piece of the
background, and it doesnt works either.
I think that the probelm may be the SDL_BlitSurface function im using.
May be theres an other way to do that ? I mean, to copy a piece of the
surface?
Remember that cBAse->frame is ONE surface, with ONE BIG BMP file, that has
some frames for my sprite animation.
The program seems to work perfectly if I use separated BMP files and
Surfaces for each frame, and in the function i wrote, using
SDL_DisplayFormat.
Thanks in advance for any help!
Eduardo Garcia Rajo (h)------------------------------------------------------------------
Visite: http://www.solucion-digital.com.ar
SOLUCION DIGITAL
Redes - Software - Servicios