Child's Play

An interactive fiction by Stephen Granade (2007) - the Inform 7 source text

Chapter 4 - Heights, Which Allow Us to Roughly Judge How High Up Something Is

Section 1 - Height Definitions

[We define heights by a parent's height. Quarter-height is knee-high. Half-height is waist-height. We also define exact heights and inexact heights. For the latter, as long as you're that height or higher you're good.]

Definition: something is half-height:
    if the baby-swing encloses it and the current speedness of the speed switch is hi, decide yes;
    if the cabinet top encloses it, decide yes;
    decide no.

Definition: something is quarter-height:
    if the tall plastic block encloses it, decide yes;
    if furniture encloses it, decide yes;
    if it is standing, decide yes;
    if it is enclosed by a standing person, decide yes;
    if the baby-swing encloses it and the current speedness of the speed switch is not hi, decide yes;
    decide no.

Definition: something is eighth-height:
    if the short plastic block encloses it or the bugish plastic block encloses it, decide yes;
    decide no.

Definition: something is half-height-or-higher:
    if it is half-height, decide yes;
    decide no.

Definition: something is quarter-height-or-higher:
    if it is quarter-height or it is half-height-or-higher, decide yes;
    decide no.

Definition: something is eighth-height-or-higher:
    if it is eighth-height or it is quarter-height-or-higher then yes;
    decide no.

Definition: something is zeroth-height:
    if it is eighth-height-or-higher then no;
    decide yes.

[Comparing heights]
To decide if (x - a thing) is higher than (y - a thing):
    if x is zeroth-height and y is eighth-height-or-higher, decide no;
    if x is eighth-height and y is quarter-height-or-higher, decide no;
    if x is quarter-height and y is half-height-or-higher, decide no;
    decide yes.

[Reachableness: from the floor, you can't reach things that are quarter height or higher. From quarter height, you can't reach zeroth-height. From half-height, you can't reach eighth-height.]
To decide if (t - a thing) is reachable by (p - a person):
    if t is a parent person, decide yes;
    if p is zeroth-height and t is quarter-height-or-higher, decide no;
    if p is quarter-height and t is zeroth-height, decide no;
    if p is half-height and t is not quarter-height-or-higher, decide no;
    decide yes.

[A message for things being out of reach]
To say out-of-reach message for (n - a thing): say "You have short arms, you can't reach [the n] from [if the player is higher than n]up[otherwise]down[end if] here."

The source code to Child's Play is licensed under a Creative Commons NonCommercial Sampling Plus 1.0 License.