Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.     REM
  2.     REM --- Tiny BASIC Interpreter and Compiler Project
  3.     REM --- Hunt the Hurkle Demostration Game
  4.     REM
  5.     REM --- Released as Public Domain by Damian Gareth Walker 2019
  6.     REM --- Created: 11-Aug-2019
  7.     REM
  8.  
  9.     REM --- Variables
  10.     REM     G: hurkle column
  11.     REM     H: hurkle row
  12.     REM     M: moves taken
  13.     REM     R: random number seed
  14.     REM     X: player guess column
  15.     REM     Y: player guess row
  16.  
  17.     REM --- Initialise the random number generator
  18.     PRINT "Think of a number."
  19.     INPUT R
  20.     IF R<0 THEN LET R=0
  21.     IF R>4095 THEN LET R=4095
  22.  
  23.     REM --- Initialise the game
  24.     GOSUB 200
  25.     LET G=R-(R/10*10)
  26.     GOSUB 200
  27.     LET H=R-(R/10*10)
  28.     LET M=0
  29.  
  30.     REM --- Input player guess
  31.  30 PRINT "Where is the hurkle? Enter column then row."
  32.     INPUT X,Y
  33.     IF X>=0 THEN IF X<=9 THEN IF Y>=0 THEN IF Y<=9 THEN GOTO 40
  34.     PRINT "That location is off the grid!"
  35.     GOTO 30
  36.  
  37.     REM --- Process player guess
  38.  40 LET M=M+1
  39.     PRINT "The Hurkle is..."
  40.     IF G<X THEN IF H<Y THEN PRINT "...to the northwest."
  41.     IF G=X THEN IF H<Y THEN PRINT "...to the north."
  42.     IF G>X THEN IF H<Y THEN PRINT "...to the northeast."
  43.     IF G>X THEN IF H=Y THEN PRINT "...to the east."
  44.     IF G>X THEN IF H>Y THEN PRINT "...to the southeast."
  45.     IF G=X THEN IF H>Y THEN PRINT "...to the south."
  46.     IF G<X THEN IF H>Y THEN PRINT "...to the southwest."
  47.     IF G<X THEN IF H=Y THEN PRINT "...to the west."
  48.     IF G=X THEN IF H=Y THEN GOTO 60
  49.     IF M>6 THEN GOTO 70
  50.     PRINT "You have taken ",M," turns so far."
  51.     GOTO 30
  52.  
  53.     REM --- Player has won
  54.  60 PRINT "...RIGHT HERE!"
  55.     PRINT "You took ",M," turns to find it."
  56.     END
  57.  
  58.     REM --- Player has lost
  59.  70 PRINT "You have taken too long over this. You lose!"
  60.     END
  61.  
  62.     REM --- Random number generator
  63.     REM     Input:   R - current seed
  64.     REM     Outputs: R - updated seed
  65. 200 LET R=5*R+35
  66.     LET R=R-R/4096*4096
  67.     RETURN