engine/source/gamelib/transform.c
// get a pixel from specific sprite
// should be fairly slow due to the RLE compression
get a pixel from specific sprite
should be fairly slow due to the RLE compression
get a pixel from specific sprite should be fairly slow due to the RLE compression
char sprite_get_pixel(s_sprite *sprite, int x, int y)
{
    int *linetab;
    register int lx = 0, count;
    unsigned char *data;
    linetab = ((int *)sprite->data) + y;
    data = ((unsigned char *)linetab) + (*linetab);
    while(1)
    {
        count = *data++;
        if(count == 0xFF)
        {
            return 0;
        }
        if(lx + count > x)
        {
            return 0;    
        }
        lx += count;
        count = *data++;
        if(!count)
        {
            continue;
        }
        if(lx + count > x)
        {
            return data[x - lx]; 
        }
        lx += count;
        data += count;
    }
    return 0;
}
char sprite_get_pixel ( s_sprite * sprite , int x , int y ) { int * linetab ; register int lx = 0 , count ; unsigned char * data ; linetab = ( ( int * ) sprite -> data ) + y ; data = ( ( unsigned char * ) linetab ) + ( * linetab ) ; while ( 1 ) { count = * data ++ ; if ( count == 0xFF ) { return 0 ; } if ( lx + count > x ) { return 0 ; } lx += count ; count = * data ++ ; if ( ! count ) { continue ; } if ( lx + count > x ) { return data [ x - lx ] ; } lx += count ; data += count ; } return 0 ; }
get a pixel from specific sprite
should be fairly slow due to the RLE compression
get a pixel from specific sprite should be fairly slow due to the RLE compression
//should we check? //if(y<0 || y>=sprite->height || x<0 || x>=sprite->width) //	return 0; // transparent pixel // not transparent pixel