Logo Search packages:      
Sourcecode: libcaca version File versions  Download package

void caca_draw_sprite ( int  x,
int  y,
struct caca_sprite const *  sprite,
int  f 
)

Draw a sprite's specific frame at the given coordinates. If the frame does not exist, nothing is displayed.

Parameters:
x The X coordinate.
y The Y coordinate.
sprite The sprite.
f The frame index.
Returns:
void

Definition at line 272 of file sprite.c.

References CACA_COLOR_BLACK, caca_get_bg_color(), caca_get_fg_color(), caca_putchar(), and caca_set_color().

{
    int i, j;
    enum caca_color oldfg, oldbg;
    struct caca_frame *frame;

    if(sprite == NULL)
        return;

    if(f < 0 || f >= sprite->nf)
        return;

    frame = &sprite->frames[f];

    oldfg = caca_get_fg_color();
    oldbg = caca_get_bg_color();

    for(j = 0; j < frame->h; j++)
    {
        for(i = 0; i < frame->w; i++)
        {
            int col = frame->color[frame->w * j + i];
            if(col >= 0)
            {
                caca_set_color(col, CACA_COLOR_BLACK);
                caca_putchar(x + i - frame->dx, y + j - frame->dy,
                           frame->chars[frame->w * j + i]);
            }
        }
    }

    caca_set_color(oldfg, oldbg);
}


Generated by  Doxygen 1.6.0   Back to index