Mail Archives: djgpp/2000/03/06/08:16:06
Dan Nicoletti <dan_nicoletti AT hotmail DOT com> wrote:
>
>void sprite_init()
>{
>blit(file[0].dat,sprite[0]->bitmap,0,0,0,0,16,16);
>blit(file[1].dat,sprite[1]->bitmap,0,0,0,0,16,16);
>etc.
>}
>
>Problem: For some reason the second blit overwrites the
>first one and I end up with the same sprite for each.
You need to allocate some memory for the sprites first:
sprite[0]->bitmap = create_bitmap(16, 16);
I would probably use a function like:
BITMAP *clone_bitmap(BITMAP *src)
{
BITMAP *b;
b = create_bitmap_ex(bitmap_color_depth(src), src->w, src->h);
if (b)
blit(src, b, 0, 0, 0, 0, src->w, src->h);
return b;
}
But you might as well use the graphics straight from the datafile structure.
sprite[0]->bitmap = file[0].dat;
Peter
- Raw text -