home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / ac6_disk / tutorial.s / hbasic3.tut / numgame.bas < prev    next >
Encoding:
BASIC Source File  |  1997-06-12  |  1.1 KB  |  62 lines

  1.  
  2. REM $option k10
  3. REM $option y+,v+,u+,[,]
  4. REM $option fNUMGAME.TOS
  5.  
  6. DEF FNgen
  7. STATIC y
  8.  
  9. DO
  10. y=CINT(RND*1000)
  11. LOOP UNTIL y<1000 AND y>0
  12. FNgen=y
  13.  
  14. END DEF
  15.  
  16. SUB game
  17. STATIC num,low,high,turn,a,a$
  18.  
  19. RANDOMIZE
  20.  
  21. num=FNgen
  22.  
  23. turn=0
  24. low=1
  25. high=999
  26.  
  27. DO
  28. INCR turn
  29. PRINT "Turn:";turn
  30. PRINT "The number is between";low;"and";high
  31. PRINT
  32.  
  33. INPUT "What do you think the number is? ",a
  34.  
  35. IF a>999 THEN STOP
  36. IF a<num THEN PRINT "The number is greater than";a : IF a>low THEN low=a
  37. IF a>num THEN PRINT "The number is below";a : IF a<high THEN high=a
  38. IF a=num THEN
  39.     PRINT
  40.     PRINT "Congratulations! The number was";num;"and you guessed correctly in";turn;"turns!" : a=1000
  41.     PRINT
  42. END IF
  43.  
  44. PRINT 
  45. LOOP UNTIL a>999
  46.  
  47. PRINT "Would you like another game?"
  48.  
  49. DO
  50. a$=UCASE$(INKEY$)
  51. LOOP UNTIL a$="Y" OR a$="N"
  52.  
  53. IF a$="Y" THEN CALL game
  54.  
  55. END SUB
  56.  
  57. PRINT "Paul's number guessing game. "+CHR$(189)+" Copyright to Paul Jones and Atari Computing"
  58. PRINT "1997. Example program using SUB/FUNCTIONS and maths functions as in"
  59. PRINT "tutorial #3."
  60.  
  61. CALL game
  62. STOP -1