Newsgroups: comp.ai.games
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!dsinc!ub!csn!news-1.csn.net!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!torn!nott!cunews!freenet.carleton.ca!FreeNet.Carleton.CA!bt422
From: bt422@FreeNet.Carleton.CA (Michael Neame)
Subject: Re: Maps & Objects
Message-ID: <Do967H.KyA@freenet.carleton.ca>
Sender: bt422@freenet3.carleton.ca (Michael Neame)
Reply-To: bt422@FreeNet.Carleton.CA (Michael Neame)
Organization: The National Capital FreeNet
References:  <4hs1nd$lbh@white.lambton.on.ca>
Date: Thu, 14 Mar 1996 10:23:41 GMT
Lines: 41

C Lambert (93004794@white.lambton.on.ca) writes:
> Does anyone have any suggestions on how to construct a map & object table 
> for a 2d tiling game?  I have the following structure using BP 7.0:
> 
> tsquare = record
>             objectindex : word;
> 	    terrain	: word;
> 	  end; {tsquare}
> tmap	= array[0..0] of tsquare;
> tmapptr = ^tmap;
> 
> { map sizes may vary from 1x1 to 125x125 in size, this method does seem 
> to cause problems (virtual arrays), can someone verify if its safe? }
> 
> tobjptr = ^tobjecttype;
> tobjecttype = record	
> 	    objindex	: word;
> 	    name	: string[10];
> 	    next, prev  : tobjptr;
> 	    ...
> 	    case objtype : word of
> 	    ...
> 	    end	
>  	  end; {tobject}
> 
> This may prove slow when the player walks about, looking through the list 
> each time.  Does anyone have any suggestions, point in the right 
> direction for some good algorithms/techniques in this matter?
> 
My method used an x by x array of integers, each describing the graphics
for that square, an x by x array of bytes with info about each square
(pass, no pass, water, land, etc) Objects I stored as a linked list; if
you sort them by x or y co-ordinate searches can be speeded up. (pointers
to middle of list.) Characters and monsters I also stored as a linked
list of objects. 
E-mail me if you have comments, or post here. I have some source code
relating to this if anyone's interested. 

-Mike N.
bt422@freenet.carleton.ca

