Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
102 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

Creating Virtual Worlds


Section 5 - Doorways to Heaven

Now 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


5: Two rooms, with corner and a door between them



Redefine the world


Contents
  Introduction
  What you need
  How it was...
  A single room
  Two rooms
  Three rooms over the edge
  Another brick in the wall
  Doorways to Heaven
  Redefine the world
  Links, routes, etc.
  More ideas
  Afterword

  Printable version
  Discuss this article