§3.6. Windows

Calvin Coolidge once described windows as "rectangles of glass." For us, they have two purposes: first, they offer a view of landscape beyond. In the simplest case the view is of an area which will not be interacted with in play, and therefore does not need to adapt to whatever may have changed there:

The window is scenery in the Turret. "Through the window you see miles and miles of unbroken forest, turning from green to flame in the hard early autumn."

More interesting is to adapt the view a little to provide a changing picture: a forest may not change much, but a street scene will. Port Royal 4 allows us to glimpse random passers-by.

The trickiest kind of window allows the player to see another room which can also be encountered in play, and to interact with what is there. Dinner is Served presents a shop window, allowing people to see inside from the street, and even to reach through.

Vitrine handles the complication of a window misting up to become opaque, and thus temporarily hiding its view.

Second, windows provide openings in walls and can act as conduits. Escape shows how a "door" in the Inform sense can become a window. A Haughty Spirit provides a general kind of window for jumping down out of: ideal for escapers from Colditz-like castles.

* See Doors, Staircases, and Bridges for a door which can be partially seen through


arrow-up.pngStart of Chapter 3: Place
arrow-left.pngBack to §3.5. Doors, Staircases, and Bridges
arrow-right.pngOnward to §3.7. Lighting

*ExampleVitrine
An electrochromic window that becomes transparent or opaque depending on whether it is currently turned on.

**ExampleEscape
Window that can be climbed through or looked through.

**ExampleDinner is Served
A window between two locations. When the window is open, the player can reach through into the other location; when it isn't, access is barred.

**ExamplePort Royal 4
A cell window through which the player can see people who were in Port Royal in the current year of game-time.

Suppose we have a game in which the player can climb through windows which overlook rooms below. We want him to be allowed to climb out windows to reach a room on the same level or at most one level lower than the one he's on; otherwise, he should get a refusal, saying that he would break his neck.

To figure out the height distance between the start room and the destination room, we might have a repeat loop look at all the directions one has to follow along the "best route" path between the two rooms, and record any ups and downs; then subtract the number of "up" steps from the number of "down" steps, and report what remains.

paste.png "A Haughty Spirit"

To decide what number is the distance (first place - a room) rises above (second place - a room):
    let the total distance be the number of moves from the first place to the second place;
    if the total distance is less than 1, decide on 0;
    let count of down moves be 0;
    let count of up moves be 0;
    let next place be the first place;
    repeat with counter running from 1 to the total distance:
        let the way be the best route from the next place to the second place;
        if the way is down, let count of down moves be the count of down moves plus 1;
        if the way is up, let the count of up moves be the count of up moves plus 1;
        let next place be the room the way from next place;
    let the decision be the count of down moves minus the count of up moves;
    decide on the decision.

Now we just have to create windows and some action rules for interacting with them...

A window is a kind of thing. A window is always fixed in place. A window can be open or closed. A window is usually closed. A window can be openable or unopenable. A window is usually openable.

Understand "climb through [something]" as entering. Understand "jump through/out [something]" as entering.

Before entering a closed window:
    say "[The noun] would have to be opened first." instead.

Instead of entering a window:
    if the noun overlooks a room (called the far side):
        let fall be the distance the location rises above the far side;
        if fall is greater than 1, say "You'd break your neck." instead;
        say "You tumble into [the far side].";
        move the player to the far side;
    otherwise:
        say "There's nowhere to go."

Instead of examining a window:
    say "[The noun] [if the noun is open]opens over[otherwise]gives a view of[end if] [the list of rooms overlooked by the noun]."

Here we must anticipate a little from the chapter on Relations, and provide ourselves with a way of keeping track of how windows and rooms relate to one another:

Overlooking relates various windows to various rooms. The verb to overlook means the overlooking relation. The initial appearance of a window is usually "[The item described] overlooks [the list of rooms overlooked by the item described]."

The Square Keep is above the Winding Staircase. The Winding Staircase is above the Motte. A crown and a broken sword are in the Motte. The Bailey is west of the Motte.

The long window is in the Keep. The long window overlooks the Bailey and the Motte. The narrow window is in the Winding Staircase. The narrow window overlooks the Bailey.

Test me with "jump through window / open window / jump through window / d / x narrow window / open window / climb through window / e / up / down".

We could then add rules to allow the player to look through windows and see things in the rooms below, but that would require more material from later chapters.

***ExampleA Haughty Spirit
Windows overlooking lower spaces which will prevent the player from climbing through if the lower space is too far below.

Suppose we have a game in which the player can climb through windows which overlook rooms below. We want him to be allowed to climb out windows to reach a room on the same level or at most one level lower than the one he's on; otherwise, he should get a refusal, saying that he would break his neck.

To figure out the height distance between the start room and the destination room, we might have a repeat loop look at all the directions one has to follow along the "best route" path between the two rooms, and record any ups and downs; then subtract the number of "up" steps from the number of "down" steps, and report what remains.

paste.png "A Haughty Spirit"

To decide what number is the distance (first place - a room) rises above (second place - a room):
    let the total distance be the number of moves from the first place to the second place;
    if the total distance is less than 1, decide on 0;
    let count of down moves be 0;
    let count of up moves be 0;
    let next place be the first place;
    repeat with counter running from 1 to the total distance:
        let the way be the best route from the next place to the second place;
        if the way is down, let count of down moves be the count of down moves plus 1;
        if the way is up, let the count of up moves be the count of up moves plus 1;
        let next place be the room the way from next place;
    let the decision be the count of down moves minus the count of up moves;
    decide on the decision.

Now we just have to create windows and some action rules for interacting with them...

A window is a kind of thing. A window is always fixed in place. A window can be open or closed. A window is usually closed. A window can be openable or unopenable. A window is usually openable.

Understand "climb through [something]" as entering. Understand "jump through/out [something]" as entering.

Before entering a closed window:
    say "[The noun] would have to be opened first." instead.

Instead of entering a window:
    if the noun overlooks a room (called the far side):
        let fall be the distance the location rises above the far side;
        if fall is greater than 1, say "You'd break your neck." instead;
        say "You tumble into [the far side].";
        move the player to the far side;
    otherwise:
        say "There's nowhere to go."

Instead of examining a window:
    say "[The noun] [if the noun is open]opens over[otherwise]gives a view of[end if] [the list of rooms overlooked by the noun]."

Here we must anticipate a little from the chapter on Relations, and provide ourselves with a way of keeping track of how windows and rooms relate to one another:

Overlooking relates various windows to various rooms. The verb to overlook means the overlooking relation. The initial appearance of a window is usually "[The item described] overlooks [the list of rooms overlooked by the item described]."

The Square Keep is above the Winding Staircase. The Winding Staircase is above the Motte. A crown and a broken sword are in the Motte. The Bailey is west of the Motte.

The long window is in the Keep. The long window overlooks the Bailey and the Motte. The narrow window is in the Winding Staircase. The narrow window overlooks the Bailey.

Test me with "jump through window / open window / jump through window / d / x narrow window / open window / climb through window / e / up / down".

We could then add rules to allow the player to look through windows and see things in the rooms below, but that would require more material from later chapters.