Creating Virtual Worlds
Section 5 - Doorways to HeavenNow let's make a doorway instead of the missing wall. Also, we want to have 4 rooms instead of the empty lower right corner of our world. A doorway is just a Thing you can place in a room. There are special functions for the most important things and their most important places, aka door and window frames, that reside at the center of a wall. You can really place them anywhere you want, but more on that later on. Define the door: $mydoor = { framethick => 0.25, texture => $txt->texture('wdplank'), floortexture => $txt->texture('rooftile'), width => 4, height => 8, }; # line 1 Please note that we don't define its length. It will then automatically get a length of twice the wall thickness, and that's what you expect (if you expect the Right Thing[tm], anyway. ;) Okay, but we must tell CoW to place the door somewhere. We have to decide whether we want to place it in room 1 or room 2. Tough decisicon, since we really want it to be placed between the rooms. Uh-oh. But don't freak out! :) Since a Thing can be placed anywhere inside a cell's border (and really even outside, if you think that's a proper place), we can just add it to one of the rooms at the border to the other, and all will be well. Also, we want it at the center of the north wall of room 2, and given only room 1, we wouldn't know where that center would be. So we have to add it to room 2. Also we should remove the nowall and clobberwall properties: $room2 = cell ( name => "Room 2", size => 16, things => [ openDoor ( aNorth(), $mydoor ),] ); # line 2 |