delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/06/12:28:05

From: "Campbell, Rolf [SKY:1U32:EXCH]" <moscoop AT americasm01 DOT nt DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Please help - Allegro/Sprites Question.
Date: Mon, 06 Mar 2000 10:49:15 -0500
Organization: Nortel Networks
Lines: 33
Message-ID: <38C3D37B.9223165@americasm01.nt.com>
References: <38C28D93 DOT 1457A457 AT hotmail DOT com>
NNTP-Posting-Host: wmerh0tk.ca.nortel.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.72 [en] (X11; I; HP-UX B.10.20 9000/785)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019