Graphical Window Sprites

version 1 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Example: ** Clickable Compass - A graphical compass rose on which the exits from the current room are highlighted. Clicking on a direction moves us appropriately. Requires that we download version 2 of Graphic Links by Jeff Sheets.

    A straightforward example in which all sprite management after the intial definition is controlled with a single rule (the compass sprites updating rule).

        "Clickable Compass"

        Include Graphical Window Sprites by Erik Temple.
        Include version 2 of Graphic Links by Jeff Sheets.

        Use full-length room descriptions.

        The graphics window proportion is 40. The graphics background color is g-white.

        When play begins:
            Now the currently shown picture is Figure of Scroll;
            now the current graphics drawing rule is the sprite-background scaled-centered display rule.

        A carry out looking rule (this is the compass sprites updating rule):
            Repeat with the way running through directions:
                let place be the room the way from the location;
                if place is a room:
                    change the dir-sprite of the way to display-active;
                otherwise:
                    change the dir-sprite of the way to display-inactive;
                follow the current graphics drawing rule.
            
        Figure of North is the file "North.png". Figure of Northwest is the file "Northwest.png". Figure of West is the file "West.png". Figure of South is the file "South.png". Figure of Southwest is the file "Southwest.png". Figure of Southeast is the file "Southeast.png". Figure of East is the file "East.png". Figure of Northeast is the file "Northeast.png". Figure of Up is the file "Up.png". Figure of Down is the file "Down.png". Figure of Inside is the file "Inside.png". Figure of Outside is the file "Outside.png". Figure of Compass Rose is the file "Compass.png". Figure of Scroll is the file "Scroll.png".

        Compass-sprite is a sprite. The sprite-identity is Figure of Compass Rose. The sprite-coordinates are {137, 93}. Compass-sprite is display-active.

        [We define the sprites themselves in table, and then we assign them to the directions. Unfortunately, Inform does not (yet?) allow us to assign sprites to already-existing things, such as the directions, from within a table. Note that all sprites are defined, even though one (outside-sprite) will never appear in the game; if we don't include an assignment to each of the directions, even those we don't plan to use, strange things will happen.]

        A direction-sprite is a kind of sprite. A direction-sprite is graphlink-active. The display-layer of a direction-sprite is 2. A direction has a direction-sprite called the dir-sprite.

        Some direction-sprites are defined by the Table of Direction Sprites.

        Table of Direction Sprites
      direction-sprite  sprite-identity  sprite-coordinates  linked replacement-command  
      north-sprite  Figure of North  {239, 93}  "GO NORTH"  
      northeast-sprite  Figure of Northeast  {307, 119}  "GO NORTHEAST"  
      east-sprite  Figure of East  {342, 196}  "GO EAST"  
      southeast-sprite  Figure of Southeast  {308, 271}  "GO SOUTHEAST"  
      south-sprite  Figure of South  {242, 298}  "GO SOUTH"  
      southwest-sprite  Figure of Southwest  {156, 271}  "GO SOUTHWEST"  
      west-sprite  Figure of West  {137, 196}  "GO WEST"  
      northwest-sprite  Figure of Northwest  {156, 119}  "GO NORTHWEST"  
      up-sprite  Figure of Up  {239, 173}  "GO UP"  
      down-sprite  Figure of Down  {232, 226}  "GO DOWN"  
      in-sprite  Figure of Inside  {213, 198}  "GO INSIDE"  
      out-sprite  Figure of Outside  {268, 200}  "GO OUTSIDE"  

        The dir-sprite of north is north-sprite. The dir-sprite of northwest is northwest-sprite. The dir-sprite of west is west-sprite. The dir-sprite of south is south-sprite. The dir-sprite of southwest is southwest-sprite. The dir-sprite of southeast is southeast-sprite. The dir-sprite of east is east-sprite. The dir-sprite of northeast is northeast-sprite. The dir-sprite of up is up-sprite. The dir-sprite of down is down-sprite. The dir-sprite of inside is in-sprite. The dir-sprite of outside is out-sprite.

        R01 is a room. R02 is north of R01. R03 is east of R01. R04 is north of R02 and northwest of R03. R05 is northeast of R02. R06 is north of R05. R07 is west of R06. R08 is southwest of R04 and northwest of R02. R09 is east of R06. R10 is northeast of R06. R11 is east of R10. R12 is southeast of R09. R13 is south of R12. R14 is northeast of R12. R14 is southeast of R11. R15 is up from R03. R16 is east of R15. R17 is north of R16. R18 is down from R17. The description of R18 is "A maze of twisty little passages, all alike. A breeze blows from the northeast."

        Exit is northeast of R18. Exit is outside from R18. The printed name of Exit is "Outside". "You emerge into sunlight." Southwest from Exit is nowhere. Inside from Exit is nowhere. After looking in Exit, end the game in victory.

        The printed name of a room is "Maze". The description of a room is usually "A maze of twisty little passages, all alike.".