Mail Archives: djgpp/1997/05/09/21:02:19
libolt AT primenet DOT com (Mike McLean) writes:
> Thanks for those who responded to my earlier question. Now I've got
> the sprite into an allegro data file. The only problem is I can't
> figure out how to display it. here is the code i am using
>
>
> #include <allegro.h>
> void main(int argc, char *argv[])
> {
> char datafile_name[80];
> int frame;
> BITMAP *spr;
> DATAFILE *data;
> strcpy(datafile_name, argv[0]);
> strcpy(get_filename(datafile_name), "cool.dat");
> set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
> data = load_datafile (datafile_name);
> set_pallete(data[1].dat);
> draw_sprite (spr, data[frame].dat,0,0);
Crashes with SIGSEGV, I guess?
You're writing the data to an uninitialized pointer which, even if
initialized, would not be the screen. I didn't look to see if there were
any other problems. Try instead
draw_sprite (screen, (BITMAP *)data[frame].dat,0,0);
Better, read the docs and try the demos. They all work (for me,
anyways), and they do most of the "tricky" stuff. Compile them. Fool
around with them. See why they do what they do.
Tom
--
See my Married... With Children index page, http://world.std.com/~tob/mwc.htm
Fox can be reached at:
Fox Network Primetime
Fox Broadcasting
P.O. Box 900
Beverly Hills, CA 90213
phone: (310) 369-1000
email: askfox AT foxinc DOT com
To beg WB or UPN to pick MWC up, visit:
http://www.primenet.com/~rnovello/bq0.htm
The e-mail for Warner Bros Television is wbnetwork AT aol DOT com
- Raw text -