RSS feeds

I've been playing with RSS feeds in JavaScript.  My first attempt is a webpage that shows the top BBC news stories; provides a Google search box and, rather uselessly displays the current day of the week.  I shall continue to work on it in an attempt to make a rather useful homepage.  Please take the code and give it to children to hack.  Have fun.  Oh, and a link to the jQuery RSS feedreader code I used.


So long Ceefax

This is a post for anyone who remembers a time before The Web, when the height of digital entertainment was the one-kilobyte-per-page, primary-coloured block-graphics wonderland that was teletext (lower-case t).  If you are still awake, and remember the joy of the Bamboozle quiz on Channel 4's Teletext (caps T) - then read on!

I was delighted to discover the Teletext Preservation Project, an attempt to archive some of the many pages from the UK teletext providers (BBC's "Ceefax", C4's "Teletext" and ITV's Oracle - which I was also delighted to discover is an acronym for Optional Reception of Announcements by Coded Line Electronics).  I have shamelessly stolen some images from the TPP for use in this post.

How we watched the 1997 general election results.  Damn you, Tony Bliar.....!!
How we celebrated.

The last ever Bamboozle screen *sob*

Utter lies, but at least the BBC coders had a sense of humour.

Other notable websites keeping teletext alive include The Teletext Museum (this link showing how the events of the 11th September 2001 were reported) and Alan Pemberton's website (an informative history of the subject).

Goodbyeee

LEGO Competition

A new Christmas tradition in my house: - LEGO competition!  Each competitor is given 16 ounces (454g) of randomly assorted LEGO bricks, and 60 minutes to build the most awesome thing.  Here are some of the best from this year's competition:

Grandpa's entry: "Space police, space toll booth".  Category - best use of sloping yellow bits.  Prize - chocolate coins.
Grandma's entry: "Archaeological dig (in space)".  Category - best story.  Prize - satsuma.  
My entry: "Humbug mobile".  Category - all round excellence.  Prize - washing up duty.

My LEGO advent calendar is complete

The LEGO advent calendar is finally complete (with a few bits left over).
Everyone will remember this scene from the movie Starwars.
Programs written in BBC BASIC for Windows

Programs written in BBC BASIC for Windows

A collection of videos showing programs written in BBC BASIC for Windows.  Also I discovered the following BB4Win facebook group.


A software simulation of the BBC One World Logo (OWL), otherwise known as the Computer Originated World (COW), rendered in real-time using Direct3D on a Windows PC by Richard Russell



This is a simulation of a novelty Ball Bearing Clock, made using BBC BASIC for Windows and the Box2D physics engine. You read the time from the bottom to the top: hours, minutes tens, minutes units, seconds tens, seconds units; it starts at five to twelve



A strange random music generator by Celtic Saint


Agitation by Celtic Saint


A load of games written in BBC BASIC for Windows by various people.


Optical illusion by dw1664 (Creator of the gfxlib)


Awesome games from a time when 'one didn't just complete video games'

A selection of BBC Microcomputer video games, from a time when games were so difficult, you did not complete them.
Thrust - a lesson in Physics, from the time when computer games were difficult.
"Probably the most challenging game for the BBC Micro" - so much so that Micro power offered cash prizes to anyone who finished it. I had a primary school teacher who was awesome (and forward thinking) enough to let us play this game ad nauseum. Never managed to complete it.
Repton - one of the greatest BBC Micro games I never owned, not that I would have completed it if I did.
The game that changed everything. Elite -the first truly 3D game. This video shows the game being played on vintage hardware. This was a true revolution in gaming. For the first time you were not limited by three lives with levels speeding up as you progress until it becomes impossible to play. Elite immersed you in a vast sandbox universe. I lost countless Friday nights as a young teen exploring the many alien worlds and battling the Thargoids and I never did manage to make it to the status of 'Elite'.  It is so good, we might do a whole series of posts on it. I wonder how many people are now spending countless nights playing Elite: Dangerous?
"We are the Arcadians" they taunted at the start of every battle. Great stuff! A fantastic version of Space Invaders for the BBC Micro. Impossible to complete, the arcadians just came at you faster and faster...
Exile - a fine example of one of the excellent adventure games for the BBC microcomputer. Did someone say 32K?
A mind-boggling and difficult adventure game featuring teleports, platforms and various beasties we came to expect from Acornsoft computer games.
Ricochet - excellent graphics and a wonderful gameplay made this game a firm favourite. I forget the name of the protagonist in this adventure, however I do remember that the aim of the game was to bounce your way through four different worlds looking for pieces of the thingy you needed to complete the game. It was a truly fiendishly difficult game, and suffice to say, I never completed it.
Baron. One of my favourite beeb games because it kind of felt like a sequel to Castle Quest. I later found out that Baron was written in a hurry to fill up space on the Acornsoft's "Play it Again Sam 11" compilation. It is not actually possible to complete this game, although I stand ready to be corrected.

Chuckie Egg. It is not possible to win, just survive longer than last time. Eventually the big yellow bird in the cage is released. If you survive that, his little blue buddies team up and kill you. Even so, this is probably one of the best games ever. They don't make games like this anymore.
Pipeline - an ingenious game with great graphics, complex puzzles and cool soundtrack. Pipeline also game with a level editor and graphics editor allowing you to spend literally days tinkering with your own levels and puzzles. One of the most memorable features of pipeline was the maze of pipes that one would enter and inevitably become hopelessly lost within...
White Magic 2 - a rogue like monster-slaying game for the beeb. This one had a level editor which was more fun than the actual game.
Ravenskull - "harder than titanium nails laminated with kryptonite!"


All of these games, and more, are available to play on the wonderful BeebEm emulator by David Gilbert.
List of browser games

List of browser games

I have started curating a list of fun browser-based games. Most are either HTML or flash. More will be added over time.
Awesome marble runs built from LEGO

Awesome marble runs built from LEGO

A collection of awesome LEGO marble runs.


Clearly the best so far. Apparently over 600 hours of work has gone into this. Be prepared to say: 'WOW', then 'WOW!', then 'OH MY GOD, WOW!!'
Another good one. Video gets more awesomer as it goes.
Close up of awesome LEGO marble run
If only I had these toys...
Another fantastic piece of work, this time a 9V powered marble run, with human loader.


It's a simple one, but a beauty!

Cute

Marble train. Someday our cities will look like this
Saving the best till last - a new world record...
Writing an Adventure Game 09

Writing an Adventure Game 09

This shall be the last post in our series on writing an adventure game in BB4W.   Posts are getting rather long, and it really is over to you to complete the game now.  If you want an example of a more complicated adventure game engine, then do check out GOLIATH.

In this edit, we have added a procedure for allowing the apple in the woods to constantly grow back once it has been eaten (ultimately preventing the player from starving to death forever).  I've also added a cake object as a special gift for all my readers - enjoy!

Source code follows:

     REM an adventure game in BB4W
     REM by Mr Street

     REM version 1.0.0.1 setting up the world
     REM version 1.0.0.2 moving around the world
     REM version 1.0.0.3 fixing it so you can't walk out of the grid
     REM version 1.0.0.4 health decreases each turn (because you get hungry)
     REM version 1.0.0.5 set-up some objects for the player to interact with
     REM version 1.0.0.6 allowing objects to be picked up
     REM version 1.0.0.7 allowing obejcts to be dropped
     REM version 1.0.0.8 eating the apple
     REM version 1.0.0.9 the apple always grows in the woods.

     REM let's set up a 'world'
     
SIZE% = 3
     DIM World$( SIZE%, SIZE% ) : REM creates a 3x3 grid
     REM now 'populate' the grid with some space names
     
PROC_populateWorld
     REM now some data about our player
     REM player's starting position
     
x% = 2
     y% = 2
     REM player's health
     
health% = 50

     REM the objects
     
numObjects% = 3 : REM start with just a small number of objects
     
DIM prefix$( numObjects% )   : REM eg "a" or "an" or "the"
     
DIM object$( numObjects% )   : REM object name, eg "sword"
     
DIM objectx%( numObjects% )  : REM object x position
     
DIM objecty%( numObjects% )  : REM object y position
     
DIM edible%( numObjects% )   : REM set to -1 for an edible object, otherwise is 0

     
PROC_createObjects
     REM a list of objects that the player has
     
DIM playerObject%( numObjects% )
     REM the apple always grows in the woods
     
appleDelay% = 10
     PROC_main
     STOP


     
DEFPROC_main
     LOCAL command$ : REM user's input
     REM the main program
     REM repeat until the player is dead
     
REPEAT
       
REM show the player's current position
       
PROC_showCurrent
       REM show objects here
       
PROC_showObjects
       REM get some input from the player
       
PRINT REM a blank line
       
INPUT "What now? > " command$
       PRINT REM a blank line
       REM deal with user's input
       
PROC_executeCommand( command$ )
       REM the apple always grows in the woods
       
PROC_growApple
     UNTIL health% <= 0
     REM game over message
     
PRINT "GAME OVER!"
     ENDPROC

     
DEFPROC_executeCommand( command$ )
     REM deals with the users input
     
LOCAL com$, gridError$
     LOCAL ok% : REM checks whether the user's input is acceptable
     
ok% = TRUE REM assume user's input makes sense
     
gridError$ = "You can't go in that direction!" : REM a message for when you move off the grid
     
com$ = FN_convlc( command$ ) : REM convert to lowercase so it is easier

     
CASE TRUE OF
       WHEN 
com$ = "n" OR com$ = "north"
         IF y%<SIZE% THEN
           
y% += 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN 
com$ = "s" OR com$ = "south"
         IF y% >1 THEN
           
y% -= 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN 
com$ = "e" OR com$ = "east"
         IF x%<SIZE% THEN
           
x% += 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN 
com$ = "w" OR com$ = "west"
         IF x%>1 THEN
           
x% -= 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN LEFT$(
com$,3) = "get"
         thisObject$ = RIGHT$(com$, LEN(com$)-4)
         PROC_getObject( thisObject$ )

       WHEN LEFT$(com$,4) = "drop"
         thisObject$ = RIGHT$(com$, LEN(com$)-5)
         PROC_dropObject( thisObject$ )

       WHEN LEFT$(com$,3) = "eat"
         thisObject$ = RIGHT$(com$, LEN(com$)-4)
         PROC_eatObject( thisObject$ )


       OTHERWISE REM this MUST be the last statement in the case
         
PRINT "I don't understand you!"
         ok% = FALSE


     ENDCASE

     
REM if the user's input was acceptable, then they have
     REM made one 'turn' and should lose one health point
     
IF ok% THEN
       
health% -= 1
     ENDIF

     ENDPROC


     
DEFPROC_showCurrent
     PRINT "----------------------------------"
     PRINT "You are at the : "World$(x%, y%)
     PRINT "Your health is : "STR$(health%)
     ENDPROC


     
DEFPROC_showObjects
     REM look for any objects here
     
LOCAL n%
     REM look through list of objects
     
FOR n% = 1 TO numObjects%
       REM is the player's location the same as the object location?
       
IF x% = objectx%(n%) AND y% = objecty%(n%) THEN
         
REM objects is here
         
PRINT "There is "prefix$(n%)" "object$(n%)" here."
       ENDIF
     NEXT
     ENDPROC


     
DEFPROC_getObject( this$ )
     REM allows player to pick up objects
     
LOCAL n%, found%, index%
     LOCAL objectError$ : objectError$ = "I don't see one of those here!"
     WHILE n% <=numObjects% AND NOT found%
       IF this$ = object$(n%) THEN
         
found% = TRUE
         
index% = n%
       ELSE
         
n% += 1
       ENDIF
     ENDWHILE
     
:
     IF found% THEN
       
REM check that the object is at the player's location
       
IF x% = objectx%(index%) AND y% = objecty%(index%) THEN
         
REM object is here, so pick it up
         
playerObject%(index%) = TRUE REM add to list of player's objects
         
objectx%(index%) = -1 : REM remove object from the grid
         
objecty%(index%) = -1 : REM remove object from the grid
         
PRINT "OK, you take "prefix$(index%)" "object$(index%)
       ELSE
         PRINT 
objectError$
       ENDIF
     ELSE
       PRINT 
objectError$
     ENDIF
     ENDPROC

     
DEFPROC_dropObject( this$ )
     REM allows player to drop objects
     
LOCAL n%, found%, index%
     LOCAL objectError$ : objectError$ = "You are not carrying one of those!"
     WHILE n% <=numObjects% AND NOT found%
       IF this$ = object$(n%) THEN
         
found% = TRUE
         
index% = n%
       ELSE
         
n% += 1
       ENDIF
     ENDWHILE
     
:
     IF found% THEN
       
REM check that the player has the object
       
IF playerObject%(index%) THEN
         
REM player has one so can drop it
         
playerObject%(index%) = FALSE REM remove from list of player's objects
         
objectx%(index%) = x% : REM add object to the grid
         
objecty%(index%) = y% : REM add object to the grid
         
PRINT "OK, you drop "prefix$(index%)" "object$(index%)
       ELSE
         PRINT 
objectError$
       ENDIF
     ELSE
       PRINT 
objectError$
     ENDIF
     ENDPROC


     
DEFPROC_eatObject( this$ )
     REM allows player to eat objects
     
LOCAL n%, found%, index%
     LOCAL healthBonus% : healthBonus% = 10 : REM health gained from eating things
     
LOCAL objectError$ : objectError$ = "You are not carrying one of those!"
     WHILE n% <=numObjects% AND NOT found%
       IF this$ = object$(n%) THEN
         
found% = TRUE
         
index% = n%
       ELSE
         
n% += 1
       ENDIF
     ENDWHILE
     
:
     IF found% THEN
       
REM check that the player has the object
       
IF playerObject%(index%) THEN
         
REM player has one so can try to eat it
         REM check whether the object is edible
         
IF edible%(index%) THEN
           
REM object is one of the edible objects
           
playerObject%(index%) = FALSE REM remove from list of player's objects
           
objectx%(index%) = -1 : REM remove object from the grid
           
objecty%(index%) = -1 : REM remove object from the grid
           
PRINT "OK, you eat "prefix$(index%)" "object$(index%)
           health% += healthBonus%
           PRINT "You gain "STR$(healthBonus%)" health points!"
         ELSE
           PRINT 
"I'm not eating one of those!"
         ENDIF
       ELSE
         PRINT 
objectError$
       ENDIF
     ELSE
       PRINT 
objectError$
     ENDIF
     ENDPROC


     
DEFPROC_growApple
     REM if the apple does not exist, then grow a new apple
     
IF objectx%(1) = -1 AND objecty%(1) = -1 AND playerObject%(1) = FALSE THEN
       
appleDelay% -= 1
     ENDIF
     IF 
appleDelay% <= 0 THEN
       
REM reset the apple delay
       
appleDelay% = 10
       REM put the apple in the woods
       
objectx%(1) = 1
       objecty%(1) = 3
     ENDIF
     ENDPROC



     
DEF FN_convlc(A$)
     REM converts to lower case
     
SYS "CharLowerBuff", !^A$, LEN(A$)
     = A$


     DEFPROC_populateWorld
     REM puts some names of the spaces into the World
     
LOCAL x%, y%
     REM start with the first row
     
FOR y% = 1 TO 3
       FOR x% = 1 TO 3
         READ World$(x%,y%)
       NEXT
     NEXT
     ENDPROC
     
:
     REM the data for our 3x3 grid
     
DATA "Hills",  "Mountains", "Forest"
     
DATA "Castle", "Village", "Fields"
     
DATA "Woods",  "Swamp",  "Lake"

     
DEFPROC_createObjects
     REM puts the names of objects into a list
     
LOCAL n%
     FOR n% = 1 TO numObjects%
       READ prefix$(n%)
       READ object$(n%)
       READ objectx%(n%)
       READ objecty%(n%)
       READ edible%(n%)
     NEXT
     ENDPROC
     DATA
 "an", "apple", 1, 3, -1
     
DATA "a",  "sword", 3, 3, 0
     
DATA "a",  "cake", 2, 2, -1

Writing an Adventure Game 08

Following the earlier post on picking up and dropping objects, we shall now look at creating objects that can be eaten (or not!).  Let's ring the changes...

A new property is required.

In order to distinguish between edible and non-edible objects (unless you want your player to eat their own sword!) we need to set up a new array to record whether each object is edible or not.  We shall use -1 to mean 'is edible' (-1 evaluates as TRUE in BB4W), and zero to indicate not edible.

Modifying the object data.

We now need to modify the porcedure that creates objects to that it reads in the new object data.  Here you can see that we have set the apple to be edible (-1) and the sword to not be edible (0).

Dealing with the player typing "eat <object>"

We have added a new procedure - PROC_eatObject() to deal with the player eating an object.  It works as follows:

LOOK THROUGH EACH OF THE OBJECTS IN THE GAME
    IF THE THING THAT THE PLAYER TYPED IN MATCHES A VALID OBJECT      FOUND OBJECT
IF FOUND OBJECT    IF PLAYER CURRENT HAS THE OBJECT

        IF OBJECT IS EDIBLE
            REMOVE OBJECT FROM LIST OBJECTS CARRIED
            REMOVE OBJECT FROM THE GAME WORLD
            CHANGE PLAYER'S HEALTH POINTS
        ELSE
           TELL PLAYER THAT OBJECT CANNOT BE EATEN
    ELSE
        TELL PLAYER THAT THEY DON'T HAVE ONE OF THOSE
ESLE
    TELL PLAYER THAT THEY DON'T HAVE ONE OF THOSE


The player can move around the map, pick up objects and eat them.  Notice the player's health changes when the apple is eaten.  You could modify it so that different objects change the health by different amounts, in which case each object would need a new property - something like 'health gained'.  In this demo, we gain 10 points for every edible object.

Next time: the apple's grow back!

Source code follows:

     REM an adventure game in BB4W
     REM by Mr Street

     REM version 1.0.0.1 setting up the world
     REM version 1.0.0.2 moving around the world
     REM version 1.0.0.3 fixing it so you can't walk out of the grid
     REM version 1.0.0.4 health decreases each turn (because you get hungry)
     REM version 1.0.0.5 set-up some objects for the player to interact with
     REM version 1.0.0.6 allowing objects to be picked up
     REM version 1.0.0.7 allowing obejcts to be dropped
     REM version 1.0.0.8 eating the apple

     REM let's set up a 'world'
     
SIZE% = 3
     DIM World$( SIZE%, SIZE% ) : REM creates a 3x3 grid
     REM now 'populate' the grid with some space names
     
PROC_populateWorld
     REM now some data about our player
     REM player's starting position
     
x% = 2
     y% = 2
     REM player's health
     
health% = 50

     REM the objects
     
numObjects% = 2 : REM start with just a small number of objects
     
DIM prefix$( numObjects% )   : REM eg "a" or "an" or "the"
     
DIM object$( numObjects% )   : REM object name, eg "sword"
     
DIM objectx%( numObjects% )  : REM object x position
     
DIM objecty%( numObjects% )  : REM object y position
     
DIM edible%( numObjects% )   : REM set to -1 for an edible object, otherwise is 0
     
PROC_createObjects
     REM a list of objects that the player has
     
DIM playerObject%( numObjects% )
     PROC_main
     STOP


     
DEFPROC_main
     LOCAL command$ : REM user's input
     REM the main program
     REM repeat until the player is dead
     
REPEAT
       
REM show the player's current position
       
PROC_showCurrent
       REM show objects here
       
PROC_showObjects
       REM get some input from the player
       
PRINT REM a blank line
       
INPUT "What now? > " command$
       REM deal with user's input
       
PROC_executeCommand( command$ )
     UNTIL health% <= 0
     REM game over message
     
PRINT "GAME OVER!"
     ENDPROC

     
DEFPROC_executeCommand( command$ )
     REM deals with the users input
     
LOCAL com$, gridError$
     LOCAL ok% : REM checks whether the user's input is acceptable
     
ok% = TRUE REM assume user's input makes sense
     
gridError$ = "You can't go in that direction!" : REM a message for when you move off the grid
     
com$ = FN_convlc( command$ ) : REM convert to lowercase so it is easier

     
CASE TRUE OF
       WHEN 
com$ = "n" OR com$ = "north"
         IF y%< SIZE% THEN
           
y% += 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN 
com$ = "s" OR com$ = "south"
         IF y% >1 THEN
           
y% -= 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN 
com$ = "e" OR com$ = "east"
         IF x%< SIZE% THEN
           
x% += 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN 
com$ = "w" OR com$ = "west"
         IF x%>1 THEN
           
x% -= 1
         ELSE
           PRINT 
gridError$
           ok% = FALSE
         ENDIF

       WHEN LEFT$(
com$,3) = "get"
         thisObject$ = RIGHT$(com$, LEN(com$)-4)
         PROC_getObject( thisObject$ )

       WHEN LEFT$(com$,4) = "drop"
         thisObject$ = RIGHT$(com$, LEN(com$)-5)
         PROC_dropObject( thisObject$ )

       WHEN LEFT$(com$,3) = "eat"
         thisObject$ = RIGHT$(com$, LEN(com$)-4)
         PROC_eatObject( thisObject$ )


       OTHERWISE REM this MUST be the last statement in the case
         
PRINT "I don't understand you!"
         ok% = FALSE


     ENDCASE

     
REM if the user's input was acceptable, then they have
     REM made one 'turn' and should lose one health point
     
IF ok% THEN
       
health% -= 1
     ENDIF

     ENDPROC


     
DEFPROC_showCurrent
     PRINT "----------------------------------"
     PRINT "You are at the : "World$(x%, y%)
     PRINT "Your health is : "STR$(health%)
     ENDPROC


     
DEFPROC_showObjects
     REM look for any objects here
     
LOCAL n%
     REM look through list of objects
     
FOR n% = 1 TO numObjects%
       REM is the player's location the same as the object location?
       
IF x% = objectx%(n%) AND y% = objecty%(n%) THEN
         
REM objects is here
         
PRINT "There is "prefix$(n%)" "object$(n%)" here."
       ENDIF
     NEXT
     ENDPROC


     
DEFPROC_getObject( this$ )
     REM allows player to pick up objects
     
LOCAL n%, found%, index%
     LOCAL objectError$ : objectError$ = "I don't see one of those here!"
     WHILE n% <=numObjects% AND NOT found%
       IF this$ = object$(n%) THEN
         
found% = TRUE
         
index% = n%
       ELSE
         
n% += 1
       ENDIF
     ENDWHILE
     
:
     IF found% THEN
       
REM check that the object is at the player's location
       
IF x% = objectx%(index%) AND y% = objecty%(index%) THEN
         
REM object is here, so pick it up
         
playerObject%(index%) = TRUE REM add to list of player's objects
         
objectx%(index%) = -1 : REM remove object from the grid
         
objecty%(index%) = -1 : REM remove object from the grid
         
PRINT "OK, you take "prefix$(index%)" "object$(index%)
       ELSE
         PRINT 
objectError$
       ENDIF
     ELSE
       PRINT 
objectError$
     ENDIF
     ENDPROC

     
DEFPROC_dropObject( this$ )
     REM allows player to drop objects
     
LOCAL n%, found%, index%
     LOCAL objectError$ : objectError$ = "You are not carrying one of those!"
     WHILE n% <=numObjects% AND NOT found%
       IF this$ = object$(n%) THEN
         
found% = TRUE
         
index% = n%
       ELSE
         
n% += 1
       ENDIF
     ENDWHILE
     
:
     IF found% THEN
       
REM check that the player has the object
       
IF playerObject%(index%) THEN
         
REM player has one so can drop it
         
playerObject%(index%) = FALSE REM remove from list of player's objects
         
objectx%(index%) = x% : REM add object to the grid
         
objecty%(index%) = y% : REM add object to the grid
         
PRINT "OK, you drop "prefix$(index%)" "object$(index%)
       ELSE
         PRINT 
objectError$
       ENDIF
     ELSE
       PRINT 
objectError$
     ENDIF
     ENDPROC


     
DEFPROC_eatObject( this$ )
     REM allows player to eat objects
     
LOCAL n%, found%, index%
     LOCAL healthBonus% : healthBonus% = 10 : REM health gained from eating things
     
LOCAL objectError$ : objectError$ = "You are not carrying one of those!"
     WHILE n% <=numObjects% AND NOT found%
       IF this$ = object$(n%) THEN
         
found% = TRUE
         
index% = n%
       ELSE
         
n% += 1
       ENDIF
     ENDWHILE
     
:
     IF found% THEN
       
REM check that the player has the object
       
IF playerObject%(index%) THEN
         
REM player has one so can try to eat it
         REM check whether the object is edible
         
IF edible%(index%) THEN
           
REM object is the apple
           
playerObject%(index%) = FALSE REM remove from list of player's objects
           
objectx%(index%) = -1 : REM remove object from the grid
           
objecty%(index%) = -1 : REM remove object from the grid
           
PRINT "OK, you eat "prefix$(index%)" "object$(index%)
           health% += healthBonus%
           PRINT "You gain "STR$(healthBonus%)" health points!"
         ELSE
           PRINT 
"I'm not eating one of those!"
         ENDIF
       ELSE
         PRINT 
objectError$
       ENDIF
     ELSE
       PRINT 
objectError$
     ENDIF
     ENDPROC





     
DEF FN_convlc(A$)
     REM converts to lower case
     
SYS "CharLowerBuff", !^A$, LEN(A$)
     = A$


     DEFPROC_populateWorld
     REM puts some names of the spaces into the World
     
LOCAL x%, y%
     REM start with the first row
     
FOR y% = 1 TO 3
       FOR x% = 1 TO 3
         READ World$(x%,y%)
       NEXT
     NEXT
     ENDPROC
     
:
     REM the data for our 3x3 grid
     
DATA "Hills",  "Mountains", "Forest"
     
DATA "Castle", "Village", "Fields"
     
DATA "Woods",  "Swamp",  "Lake"

     
DEFPROC_createObjects
     REM puts the names of objects into a list
     
LOCAL n%
     FOR n% = 1 TO numObjects%
       READ prefix$(n%)
       READ object$(n%)
       READ objectx%(n%)
       READ objecty%(n%)
       READ edible%(n%)
     NEXT
     ENDPROC
     DATA
 "an", "apple", 1, 3, -1
     
DATA "a",  "sword", 3, 3, 0

Label