🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #105

Re: data structure for dungeons

#105
From: peter.l.berghold
Date: Tue, 22 Aug 1989 14:34
52 lines
2740 bytes
In article <Aug.20.16.38.37.1989.24164@porthos.rutgers.edu> sofmac@porthos.rutgers.edu (Sofus Macskassy) writes:
>
>I am trying to build up a 3d dungeon, but can't figure out
>what kind of data structure to use.  I don't want to use 
>arrays, but would rather use some kind of linked list.
>If somebody knows a good and short structure, that uses
>minimal memory, I would appreciate it if they would mail
>me at sofmac@porthos.rutgers.edu


Your data structures would depend on what kind of data that you would be 
includeing in each record.   However, for sake of generalization, here is a 
scheme that might work.

--------------- code starts here...
typedef struct Dimensions{
	int	height,width,length;	/* Self explainatory */
} Dimensions;

typedef struct DungeonPiece {
	enum type={corridor,room,door,..etc... you get the idea};
	Dimensions	dimensions;
	struct DungeonPiece **MadeOf;	/* All the pieces that make this peice*/
	struct DungeonPiece *Next; /* Next room, corrideor, etc. */
} DungeonPiece;

typedef struct DungeonLevel {
	struct DungeonLevel	*NextLevel,*LastLevel;
	DungeonPiece		*FirstPiece;
} DungeonLevel;

      |
-------------- code ends here...


In this manner your dungeon goes together as a linked list of pieces with 
the last piece pointing to (DungeonPiece *)0.  You could simplify the coding
of it by creating "black box" modules of code that operate on one data type 
at a time and just handing off the neccesary information to them.  If you have
access to a C++ compiler, the whole thing could be handled as "objects"....


Pete

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|     _   /|    || Peter L. Berghold, AT&T, HRSAG, UUCP: att!violin!plb        |
|     \`o_O'    ||============================================================ |
|       ( )     || Disclaimer: If you find an opinion in this posting somewhere|
|        U      || it is no doubt mine, and not my employers.  I'm the only    |
|    Aachk!     || person crazy enough to take this stand!                     |
|        Phft!  ||                                                             |
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Technical Details
Message-ID: <611@cbnewsi.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!rutgers!dptg!att!cbnewsi!plb
References: <Aug.20.16.38.37.1989.24164@porthos.rutgers.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!rutgers!dptg!att!cbnewsi!plb
From: plb@cbnewsi.ATT.COM (peter.l.berghold)
Newsgroups: rec.games.programmer,comp.lang.c
Subject: Re: data structure for dungeons
Message-ID: <611@cbnewsi.ATT.COM>
Date: 22 Aug 89 14:34:18 GMT
References: <Aug.20.16.38.37.1989.24164@porthos.rutgers.edu>
Reply-To: plb@cbnewsi.ATT.COM (peter.l.berghold,hr,)
Distribution: na
Organization: AT&T Bell Laboratories
Lines: 52