From: Ryan Blazecka Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro Newbie (sprites/tiles) Date: Sun, 02 Nov 1997 00:14:55 -0800 Organization: BCTEL Advanced Communications Lines: 51 Message-ID: <345C367F.9A9@bc.sympatico.ca> References: <345AD7C5 DOT 3628D59A AT csun DOT edu> Reply-To: eblazecka AT bc DOT sympatico DOT ca NNTP-Posting-Host: srry01m01-30.bctel.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Ryan Bright wrote: > I have sprite (and tile) files in raw data format (1028 bytes) and > I've spent a couple of days trying to figure out how to load them and > display them with Allegro but to no avail. What's the preferred > method? I was planning on using RLE_SPRITE, but how would I go about > loading them off the HD into the data structure? And then, you can load the data from the HD directly into a bitmap. (I am assuming the RAW files are 32x32 8-bit bitmaps, with a word value for width and height each.) If this is so, then the following code should load them into a BITMAP: BITMAP *image = create_bitmap(32, 32); //create bitmap to store tile PACKFILE *fp = pack_fopen("tile.raw", F_READ); //open tile file pack_igetl(fp); //throw away size info, since you know it is 32x32 pack_fread(image->dat, 32*32, fp); //read the tile data into the bitmap pack_fclose(fp); //close the file when you're done with it You can now use image as a regular bitmap, passing it to blit, draw_sprite, or whatever. > If I use RLE sprites, then I don't see any "blit" equivalent. So what > do I do with the tiles in which I don't want to use masking (skip 0)? > Do I have to use a BITMAP and waste all that space? When you don't want to skip 0's, use regular BITMAPs. RLE sprites only compress color 0's, so there is no speed or memory gain for using RLE sprites in this case. > Continuation of first Q : I'd love to use the included "grabber" > software to store all these RLE sprites into a single data file, but I > don't quite see how to load them in.. it only accepts .dat files. And > if I create a "new..." object then, once again, how do I load in my raw > data sprites?...and convert to run-length? tia Using the grabber is a much better way to go than loading all the bitmaps directly. You need to get your images into a format Allegro can use, though (PCX,BMP,TGA, or LBM). The program you used to create your images should be able to do this for you. The rest is explained in detail in grabber.txt. > btw, when I say newbie, I mean I heard about djgpp and allegro for the > first time 3 days ago, so detailed answers would be _MUCH_ > appreciated... thanks (I am assuming you are familiar with C though :). -- [ Ryan Blazecka -- http://www.deninc.com/~corrosion/ ] [ _corrosion_ AT geocities DOT com OR eblazecka AT bc DOT sympatico DOT ca ]