🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: rec.games.programmer
2 messages
2 total messages Started by Sofus Macskassy Sun, 20 Aug 1989 20:38
data structure for dungeons
#104
Author: Sofus Macskassy
Date: Sun, 20 Aug 1989 20:38
10 lines
763 bytes
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

   thanks in advance
	     -- Sofus
Re: data structure for dungeons
#105
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads