[DM-dev] rendering of rooms works.
Brought to you by:
acdalton,
henningsen
From: Stephan B. <st...@wa...> - 2001-04-28 21:50:40
|
Here's a sample: DungeonElement top( "dungeon" ); DungeonElement *de = new Room(); de->setName( "roomX" ); de->move( 3, 5 ); top.add( room ); de = new Room( 7,3, "wide room" ); de->move( 17,4 ); top.add( de ); de = new Room( 5,8, "tall room" ); de->move( 10,1 ); top.add( de ); DMGrid grid( 20, 20 ); CERR << "after rendering:" << endl; top.renderTo( grid ); grid.dump(); (Doors will be added later.) Note how all of that is done through the generic DungeonElement API, and not Room's specific API. Basically, anything which goes in a Dungeon in a DungeonElement, and has lots of behaviour in common (moving, resizing, etc.), though each may implement that completely differently. This code draws us with the following map: 00000000000000000000 00000000001111100000 00000000001000100000 00000000001000100000 00000000001000100111 00011111001000100100 00010001001000100111 00010001001000100000 00010001001111100000 00011111000000000000 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000000000 (Sorry for the ugly output - I haven't yet got the char/int mapping support done.) DMGrid provides a resizable grid. If it's resized, though, all renderings are nuked. Any attempts to write outside it's boundaries are ignored. You'll see that in the above map, the "wide room" overflows off the side. The rendering code is spread out: the recursive functionality is in DungeonElement. The actual drawing of data is left to the subclasses. Room draws nothing, but it's 4 children each draw themselves. See ya! ----- Stephan Beal - st...@wa... http://qub.sourceforge.net - http://stephan.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 |