-
Notifications
You must be signed in to change notification settings - Fork 0
Ch 2. Make Making Rooms Section 3 Rooms and Regions
In adv3lite, there is only one time of room, however there are things that we can do to customize our rooms. Most room start lit, however we can make them dark. You can do this by defining the “isLit” property as “nil”, or simply the room isn’t lit. If your character doesn’t have a light source, you won’t see anything. We’ll discuss Darkness and Light further in chapter 10. If you plan to have lots of dark rooms in your game, you may want to define a “DarkRoom” class.
You can make defintions such as:
This takes advantage of something in programming called ‘inheritance’. In object-oriented programming, inheritance is the mechanism of basing an object or class on a previously defined class.The new object, or class, in this case, will inherit all the properties from the predefined class “Room”.
You can also assign rooms to a Region. A Region is a set of rooms that belong together in some way.
Examples:
- Rooms of a House
- Downstairs Rooms
- Upstairs Rooms
- Outside Rooms
Rooms can belong to multiple regions. Regions can also be assigned to regions. You can have a hall that is in the downstairs region of a myHome region:
Regions could be used for a variety of things. You can test whether the player, or something is in a region. You can restrict what happens in a region. Example: only use directions like ‘port’, ‘starboard’, fore, and ‘aft’ when you’re on a ship.
This property would appear if the player tried to go in any direction that we haven’t defined an exit for.
Notice that we are using backslash () immediate before a single-quote marks that we want to appear within a single-quoted string property.
Here's an alternative to that:
This avoids the need to type the backslash, which can get awkward at times.
Try to construct a map using the properties that were introduced in this chapter!
Examples:
- A house and part of its garden
Try assigning some of these parts to appropriate regions.
Here’s an example of what you might want to do using these more advanced properties!