delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/14/15:03:06

Newsgroups: comp.os.msdos.djgpp
From: "A. Jans-Beken" <jabe AT oce DOT nl>
Subject: Re: Allegro Bitmap Array...
Message-ID: <355AD6EE.9E2822EC@oce.nl>
Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl)
Organization: Oce-Technologies B.V. - Research & Development
References: <6hqlq3$jdo AT nnrp1 DOT farm DOT idt DOT net>
Mime-Version: 1.0
Date: Thu, 14 May 1998 11:35:11 GMT
Lines: 44
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Chia wrote:

> I want to create a two dimensional array of bitmaps for a terrain-selector
> for a map-builder I'm making.  I also want them to be in the heap so they
> don't use up all the conventional ram.
>
> How would I go about mallocing this array, and would the declaration look
> like this:
>
> BITMAP ***TerrainArray;
>

This is not a good idea because every BITMAP struct takes up a "lot" of memory
(128 bytes or so).

I think that it would be better to define a small set of "tiles" and reuse
these tiles in a following manner:

// Demo of TerrainArray
// By A. Jans-Beken

<-- standard include stuff -->
// An array of bitmaps containing tile graphics only once.
BITMAP *TileSet[MAX_NUM_OF_DIFFERENT_TILES];
unsigned char TerrainArray[MAX_COLUMNS][MAX_ROWS];

main() {
   int i,j;

   // Read all tile-graphics from file.
   // Define terrain by filling-in values (0 .. 255) in TerrainArray.

   for (j = 0; j < MAX_ROWS; j++)
      for (i = 0; i < MAX_COLUMNS; i++)
         blit(screen, TileSet[TerrainArray[i][j]], .......);
   // Note: For large TerrainArray only a small "window" can be seen on the
screen.
   }

For an example with source code:
http://www.geocities.com/SiliconValley/Bay/4413/

have fun...

- Raw text -


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