delorie.com/archives/browse.cgi   search  
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: <34D0DFE6.3A46@nic.smsu.edu>
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
NNTP-Posting-Host: clark.a38.smsu.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.

[snip]
 
> 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:

draw_sprite(screen,datafile[BLANK].dat,0,0);

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




The above is the same as:

draw_sprite(screen,datafile[2].dat,0,0);

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

int SpriteNumber;
int ContinueLoop;

while (ContinueLoop)
  {
  SpriteNumber = GetSpriteNumberFromWherever();
  draw_sprite(screen,datafile[SpriteNumber].dat,Xcor,Ycor);
  ContinueLoop = AskUserToContinueLoop();
  }

-- 
Tony O'Bryan

http://www.geocities.com/SiliconValley/Park/7201

- Raw text -


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