[DM-dev] I've got it: the best of both models...
Brought to you by:
acdalton,
henningsen
From: Stephan B. <ste...@ei...> - 2001-06-30 13:09:41
|
We can have our cake and eat it, too... DungeonElement is going to stay completely heirarchical. I can use these objects in QUB to make a visual dungeon editor. But... For DM I'm adding a Dungeon object, which has methods similar to: addRoom( x,y,w,h, doorSide, doorX=-1, doorY=-1, doorWidth=2 ) // doorSide = N/S/E/W // (-1 == try to center it based off of the doorSide) addWall( x, y, w, h ) // like addRoom(), but makes a filled-in area addArea( x, y, w, h, square_type ) // the main function which most other addXXX()'s use to do their work. The Dungeon object will be used as the only "gateway" into the DungeonElement object, and the Dungeon user will never see DungeonElement. Dungeon's structure will enforce that a Dungeon: a) cannot be made out of a hierarchical structure. b) is in "auto-commit" mode. What I mean by that is that once a user calls addRoom(), he cannot go back and delete that room. It will render itself to a grid as the functions are called, instead of via a render() function. The internal implementation of Dungeon will use DungeonElements, simply because I've already got the list management and file output code written ;). The libDM user won't ever know that, though. Going through the Dungeon object enforces that there won't be a hierarchy of objects, since those have grief when dealing with a flat input/output source. Basically it will have to use DungeonElements unless I also want to write the output file data as addXXX() is called. Otherwise I won't be able to construct a list of rooms/walls/doors to save! DungeonElement already has the list-maintenance code needed for that, also, so there's no reason not to use them, as long as the user is shielded from having access to them. This is also future-compatible: in the case that I come up with some really brilliant ;) way of saving/loading hierarchies from flat files, I'll re-add the hierarchy support to libDM to give it that flexibility. :) ----- Stephan Beal - st...@wa... http://qub.sourceforge.net - http://gwm.rootonfire.org http://byoo.rootonfire.org - http://dungeonmaker.sourceforge.net "Now I'm not normally the kind of person who likes to trespass, but sometimes you just find yourself over the line." -- Bob Dylan |