Mail Archives: djgpp/1998/01/31/11:06:55

From: "Tony O'Bryan" <aho450s AT nic DOT smsu DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro Datafiles - More Problems
Date: Thu, 29 Jan 1998 14:00:39 -0600
Organization: Southwest Missouri State University
Lines: 58
Message-ID: <>
References: <MPG DOT f39e7cbc8b4c11d9896bd AT news> <19980129094901 DOT EAA26113 AT ladder02 DOT news DOT aol DOT com> <MPG DOT f3a9094a793600b9896bf AT news>
Reply-To: aho450s AT nic DOT smsu DOT edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Matt Riker wrote:

> Woops, I said that wrong.  Here is my variable declaration:
>    char spritename[20] = "BLANK";
> That's valid, right?

That's a valid C initializer, but you're heading in the wrong direction
about using it with an Allegro datafile.
> The header and stuff's all taken care of with Grabber, and I've checked
> just to verify.  BLANK is declared in my datafile, as a BMP.

> Except that I don't want the function to always draw BLANK to the
> screen.  I want to use my variable, spritename, because the sprite I
> want drawn is depending on which sprite the user chooses in my program.

When BLANK is defined in the header file, it is associating the work
BLANK with some number.  Let's say the number happens to be 2:

#define IMAGE0 0
#define IMAGE1 1
#define BLANK 2

This gives BLANK the value of 2.

In draw_sprite(), you use BLANK like this:


So far we're in agreement, right?  If so, follow on..

The above is the same as:


The following code fragment demonstrates how to draw the user-selected

int SpriteNumber;
int ContinueLoop;

while (ContinueLoop)
  SpriteNumber = GetSpriteNumberFromWherever();
  ContinueLoop = AskUserToContinueLoop();

Tony O'Bryan

- Raw text -

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