Mail Archives: djgpp/2000/03/06/12:28:05
Dan Nicoletti wrote:
> typedef struct _sprite
> {
> ... some variables...
> BITMAP *bitmap;
> }SPRITE;
>
> SPRITE *sprite[10];
>
> 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 never allocate space for either the sprite's or the bitmap's. You've
declared an array of 10 pointers to sprites, but you've never created any
sprites. You should probably just have:
SPRITE sprite[10];
Also, you need to create your bitmaps. You can't just blit to an
uninitialized bitmap.
--
(\/) Rolf Campbell (\/)
- Raw text -