home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 15
/
015.d81
/
lk.higher-lower
< prev
next >
Wrap
Text File
|
2022-08-26
|
2KB
|
78 lines
0010 //higher-lower game -- written in
0020 //comal by joel ellis rea for
0030 //the comal corner section of
0040 //loadstar -- july, 1985
0050 //
0060 title'and'instructions
0070 repeat
0080 number#:=rnd(0,999)
0090 tries#:=0
0100 repeat
0110 guess#:=get'guess#
0120 tries#:+1
0130 case sgn(number#-guess#) of
0140 when -1
0150 too'high(guess#)
0160 when 0
0170 just'right(guess#,tries#)
0180 when 1
0190 too'low(guess#)
0200 endcase
0210 until number#=guess#
0220 until not play'again#
0230 //
0240 proc title'and'instructions closed
0250 print chr$(147), //clear screen
0260 print "higher-lower game"
0270 print "by joel ellis rea"
0280 print
0290 print "i will think of a number between 0 and"
0300 print "999, and you try to guess it. after"
0310 print "each guess, i will tell you if you"
0320 print "are too high or too low. it should"
0330 print "take you no more than 12 guesses!"
0340 print
0350 endproc title'and'instructions
0360 //
0370 func get'guess# closed
0380 repeat
0390 input "your guess? ": guess#
0400 if guess#<0 or guess#>999 then
0410 print guess#;"isn't between 0 and 999!"
0420 print
0430 endif
0440 until guess#>=0 and guess#<=999
0450 return guess#
0460 endfunc get'guess#
0470 //
0480 proc too'high(guess#) closed
0490 print guess#;"is too high! try a lower number."
0500 print
0510 endproc too'high
0520 //
0530 proc too'low(guess#) closed
0540 print guess#;"is too low! try a higher number."
0550 print
0560 endproc too'low
0570 //
0580 proc just'right(guess#,tries#) closed
0590 print guess#;"is my number! it took you";tries#;"tries!"
0600 print
0610 endproc just'right
0620 //
0630 func play'again# closed
0640 dim key'press$ of 1
0650 print "do you want to play again?";
0660 repeat
0670 key'press$:=key$
0680 until key'press$ in "YyNn"
0690 if key'press$ in "Yy" then
0700 print "yeah!"
0710 return true
0720 else
0730 print "nope."
0740 return false
0750 endif
0760 endfunc play'again#
0770 //