home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug091.arc / HANGMAN.BAS < prev    next >
BASIC Source File  |  1979-12-31  |  3KB  |  83 lines

  1. 10 REM altered to the size it is by A. L. BARFOOT.  18/4/88
  2. 20 REM MBUG AUSTRALIA INC., Box 157, NUNAWADING, Vic 3131 Australia.
  3. 30 REM Converted from Microbee Basic to MBASIC by AJL 23/10/91
  4. 32 CLS$=CHR$(26): REM <-- Clear screen & Home cursor 
  5. 34 DEF FNCUR$(X,Y)=CHR$(27)+"="+CHR$(31+X)+CHR$(31+Y): REM <-- Cursor Addressing
  6. 50 GOTO 1000
  7. 90 REM **** COMPUTER FINDS WORD ****
  8. 100 PRINT CLS$
  9. 101 PRINT:PRINT "The hangman has to get some rope."
  10. 102 PRINT:PRINT"He has 26 shops to buy rope from and "
  11. 103 PRINT"over 29,872 different makes of rope to select from!"
  12. 104 PRINT:PRINT "Please wait while I get my rope."
  13. 105 RANDOMIZE SEED
  14. 106 A = INT(RND*26)+1
  15. 107 A = A + 64
  16. 109 C0$ = CHR$(A)+"DICT.DAT"
  17. 110 OPEN "I",1,C0$
  18. 120 INPUT #1,A
  19. 130 I=INT(RND*A)+1
  20. 140 FOR J=1 TO I:INPUT #1,W1$:NEXT J
  21. 145 CLOSE #1
  22. 150 RETURN
  23. 200 REM **** GET WORD FROM PERSON ****
  24. 210 PRINT:INPUT "WORD > ";W0$
  25. 220 IF LEN(W0$)>15 THEN PRINT CHR$(7)"Too long, must be < 15 letters!":GOTO 210
  26. 230 FOR X= 1 TO LEN(W0$):W=(ASC(MID$(W0$,X,1)) AND 95):W1$=W1$+CHR$(W):NEXT
  27. 240 RETURN
  28. 300 REM ***CHECK IF KEY IS IN WORD***
  29. 310 J=0:FOR I=1 TO LEN(W1$)
  30. 320 IF MID$(W1$,I,1)=A1$ THEN N(I)=1:J=1
  31. 330 NEXT I
  32. 335 IF J=0 THEN PRINT CHR$(7);
  33. 340 IF J<>0 OR A1$=" " THEN RETURN
  34. 350 REM **** DRAW HANGMAN ****
  35. 352 REM IF ASC(A1$)>64 AND ASC(A1$)<91 THEN RETURN
  36. 355 H=H+1
  37. 357 IF ASC(A1$)>64 AND ASC(A1$)<91 THEN PRINT FNCUR$(20,ASC(A1$)-55);A1$
  38. 360 IF H=1 THEN PRINT FNCUR$(20,50);"---------"
  39. 370 IF H=2 THEN FOR X=1 TO 10:PRINT FNCUR$(20-X,54);"|":NEXT X
  40. 380 IF H=3 THEN PRINT FNCUR$(9,54);"--------"
  41. 390 IF H=4 THEN FOR X=0 TO 3:PRINT FNCUR$(12-X,55+X);"/":NEXT X
  42. 400 IF H=5 THEN print FNCUR$(10,61);"|"
  43. 420 IF H=6 THEN gosub 800
  44. 430 IF H=7 THEN for x=0 to 3:print FNCUR$(14+x,61);"|":next x
  45. 440 IF H=8 THEN print FNCUR$(15,58);"\__"
  46. 450 IF H=9 THEN print FNCUR$(15,62);"__/"
  47. 460 IF H=10 THEN print FNCUR$(18,60);"/";FNCUR$(19,58);"_/"
  48. 470 IF H=11 THEN print FNCUR$(18,62);"\";FNCUR$(19,63);"\_"
  49. 480 IF H<>11 THEN RETURN
  50. 485 PRINT FNCUR$(2,1);"You didn't get it."
  51. 490 PRINT FNCUR$(4,1);"The word was :  ";W1$
  52. 494 PRINT:PRINT"Try a DICTIONARY!"
  53. 500 GOTO 2000
  54. 550 FOR H=1 TO 11:GOSUB 360:NEXT H:END
  55. 800 print FNCUR$(11,59);"/~~~\"
  56. 810 print FNCUR$(12,59);"|O.O|"
  57. 820 print FNCUR$(13,59);"\_=_/"
  58. 830 return
  59. 1000 PRINT CLS$:PRINT TAB(31);" H A N G M A N "
  60. 1010 PRINT:PRINT"This is the old fashioned game of Hangman, but it has been computerised."
  61. 1015 PRINT "You can have one player (against the computer) or two players (one types"
  62. 1020 PRINT "in the word and the other one guesses it)."
  63. 1030 PRINT :PRINT "PLAYERS (1/2) ? ";
  64. 1040 A1$=INKEY$:SEED = SEED + 1
  65. 1042 IF A1$<>"1" AND A1$<>"2" THEN 1040
  66. 1045 PRINT A1$
  67. 1050 IF A1$="1" THEN GOSUB 100 ELSE GOSUB 200
  68. 1060 DIM N(LEN(W1$)):FOR I=1 TO LEN(W1$):N(I)=0:NEXT I
  69. 1065 A1$=" ":GOSUB 300
  70. 1067 PRINT CLS$
  71. 1070 J=0:FOR I=1 TO LEN(W1$)
  72. 1080 PRINT FNCUR$(10,10+I*2);:IF N(I)=0 THEN PRINT "_":J=1 ELSE PRINT MID$(W1$,I,1)
  73. 1090 NEXT I
  74. 1095 IF J=0 THEN PRINT FNCUR$(4,1);"You guessed it!":GOTO 2000
  75. 1100 PRINT FNCUR$(13,15);"LETTER  > ";
  76. 1120 A7$=INKEY$:IF A7$="" THEN 1120
  77. 1130 X=(ASC(A7$) AND 95):A1$=CHR$(X):PRINT A1$:GOSUB 300
  78. 1140 GOTO 1070
  79. 2000 PRINT FNCUR$(16,1);"Do you want another game (Y/N) ? ";
  80. 2010 A$=INKEY$:IF A$="" THEN 2010
  81. 2020 IF A$="N" OR A$="n" THEN PRINT:PRINT "Catch you later.":END
  82. 2030 RUN
  83.