mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
- repaired wrong decompressing defs type 2 (mainly effected shadows)
- fixed #34 - correctly working most of CCreatureHandler (except displaying only specific part of animation)
This commit is contained in:
parent
e44c6b47f3
commit
8c651b5021
@ -1094,8 +1094,15 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
LOCPLINT->adventureInt->update(); //updating screen
|
||||
CSDL_Ext::update(ekran);
|
||||
CGI->screenh->updateScreen();
|
||||
LOCPLINT->adventureInt->anim++;
|
||||
adventureInt->animValHitCount=0;
|
||||
|
||||
++LOCPLINT->adventureInt->animValHitCount; //for animations
|
||||
if(LOCPLINT->adventureInt->animValHitCount == 4)
|
||||
{
|
||||
LOCPLINT->adventureInt->animValHitCount = 0;
|
||||
++LOCPLINT->adventureInt->anim;
|
||||
LOCPLINT->adventureInt->updateScreen = true;
|
||||
}
|
||||
|
||||
SDL_framerateDelay(mainFPSmng); //for animation purposes
|
||||
} //for(int i=1; i<32; i+=4)
|
||||
//main moving done
|
||||
|
@ -603,6 +603,11 @@ CCreatureAnimation::CCreatureAnimation(std::string name)
|
||||
//}
|
||||
//delete FDef;
|
||||
//FDef = NULL;
|
||||
|
||||
//init vars
|
||||
curFrame = 0;
|
||||
type = -1;
|
||||
frames = totalEntries;
|
||||
}
|
||||
|
||||
int CCreatureAnimation::readNormalNr (int pos, int bytCon, unsigned char * str, bool cyclic)
|
||||
@ -638,6 +643,8 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y)
|
||||
return -1; //not enough depth
|
||||
|
||||
int SIndex = curFrame++; //TODO: finish
|
||||
if(curFrame>=frames)
|
||||
curFrame = 0;
|
||||
|
||||
long BaseOffset,
|
||||
SpriteWidth, SpriteHeight, //format sprite'a
|
||||
@ -750,7 +757,7 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y)
|
||||
{
|
||||
for (int k=0;k<SegmentLength+1;k++)
|
||||
{
|
||||
FTemp+=fbuffer[k];//
|
||||
FTemp+=SegmentType;//
|
||||
//FTemp+='\0';
|
||||
}
|
||||
TotalRowLength+=SegmentLength+1;
|
||||
@ -784,9 +791,36 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y)
|
||||
{
|
||||
for (int j=0;j<FullWidth+add;j++)
|
||||
{
|
||||
*((char*)dest->pixels + dest->format->BytesPerPixel * ((i + y)*dest->pitch + j + x)) = FTemp[i*(FullWidth+add)+j];
|
||||
if( i+y<dest->h && j+x<dest->w)
|
||||
{
|
||||
unsigned char coln = FTemp[i*(FullWidth+add)+j]; //number of color from palette
|
||||
if(coln==0)
|
||||
continue;
|
||||
unsigned char* ptr = ((unsigned char*)dest->pixels + dest->format->BytesPerPixel * ((i + y)*dest->w + j + x));
|
||||
if(coln>7 || coln == 5) //normal or yellow border
|
||||
{
|
||||
*ptr = palette[coln].B;
|
||||
*(ptr+1) = palette[coln].G;
|
||||
*(ptr+2) = palette[coln].R;
|
||||
}
|
||||
else if(coln<5) //shadow
|
||||
{
|
||||
*ptr = ((*ptr) * (palette[coln].G + 50)) /200;
|
||||
*(ptr+1) = ((*(ptr+1)) * (palette[coln].G + 50)) /200 ;
|
||||
*(ptr+2) = ((*(ptr+2)) * (palette[coln].G + 50)) /200 ;
|
||||
}
|
||||
else if(coln == 6) //yellow border shadowed
|
||||
{
|
||||
*ptr = ((*ptr) + palette[coln-1].B) / 2;
|
||||
*(ptr+1) = ((*(ptr+1)) + palette[coln-1].G) / 2;
|
||||
*(ptr+2) = ((*(ptr+2)) + palette[coln-1].R) / 2;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UpdateRect(dest, x, y, FullWidth+add, FullHeight);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user