QBASIC GAME : HANGMAN 3

QBASIC GAME : HANGMAN 3



 ' Note: When you win a game, you get a free turn on your next game if your
 ' first guess is wrong.
 '
 DEFINT A-Z
 DECLARE SUB tletter (wletter$)
 DECLARE SUB start ()
 DECLARE SUB lost ()
 DECLARE SUB calculate ()
 DECLARE SUB ending ()
 DECLARE SUB endscreen ()
 DECLARE FUNCTION test ()
 CLEAR : RANDOMIZE TIMER: SCREEN 13: CLS : OPTION BASE 1
 CONST numberofwords = 650
 '$STATIC
 DIM SHARED already AS INTEGER
 DIM SHARED nwrong AS INTEGER
 DIM SHARED curword AS STRING
 DIM SHARED length AS INTEGER
 DIM SHARED curletter AS STRING * 1
 DIM SHARED letters(20) AS STRING
 DIM SHARED words(numberofwords) AS STRING
 
 CLS
 COLOR 15
 LOCATE 2, 1
 PRINT " LOADING WORDS . . ."
 
 FOR p = 1 TO numberofwords
 READ words(p)
 NEXT p
 
 ON ERROR GOTO ohno
 
 already = 0
 
 begin:
 start
 
 GOSUB bgnd
 GOSUB drawboard
 
 FOR c = 1 TO UBOUND(letters)
 letters(c) = ""
 NEXT c
 
 curword = ""
 length = 0
 curletter = ""
 nwrong = 0
 curword = words(INT(RND(1) * numberofwords + 1)): length = LEN(curword)
 COLOR 15
 LOCATE 18
 PRINT " ";
 'REDIM letters(length) AS STRING
 FOR l = 1 TO length
 letters(l) = MID$(curword, l, 1)
 PRINT "__ ";
 NEXT l
 LOCATE 20
 PRINT " ENTER YOUR GUESS FOR A LETTER"
 FOR l = 1 TO 11
 IF test = 1 THEN ending: GOTO begin
 DO: curletter = UCASE$(INKEY$): LOOP WHILE ASC(curletter) < 65 OR ASC(curletter) > 90
 IF test = 1 THEN ending: GOTO begin
 FOR isit = 1 TO length
 IF test = 1 THEN ending: GOTO begin
 IF curletter = letters(isit) THEN SOUND 400, 5: LOCATE 18, isit * 4 - 2: PRINT curletter + " ": plo = 1: GOTO 20
 IF test = 1 THEN ending: GOTO begin
 20 NEXT isit
 IF test = 1 THEN ending: GOTO begin
 tletter curletter
 curletter = ""
 IF test = 1 THEN ending: GOTO begin
 IF plo = 0 THEN SOUND 100, 5: nwrong = nwrong + 1: calculate
 IF plo = 1 THEN l = l - 1
 IF test = 1 THEN ending: GOTO begin
 plo = 0
 IF test = 1 THEN ending: GOTO begin
 NEXT l
 lost
 GOTO begin
 END
 
 DATA "JAZZ", "DOG", "CAT", "PICTURE", "INVENT", "ZERO", "YELLOW", "LOOP", "TYPE", "COMPUTER"
 DATA "QBASIC", "ROPE", "AMAZING", "TERRIBLE", "BOOK", "ESCAPE", "SKIP", "GIRAFFE", "RAGTIME", "PAINT"
 DATA "GALLON", "COMMA", "FORGE", "DISKETTE", "TEST", "SCIENCE", "MILL", "SHOULD", "HELLO", "MAT"
 DATA "PATENT", "VAST", "SCROLL", "OPEN", "LOCATION", "WINDOW", "PRINTER", "BUTTON", "PLAY", "THE"
 DATA "FOOL", "POST" , "DOLL", "MONEY", "ORANGE", "LEND", "MORE", "BUBBLE", "MUSIC", "PEPPER"
 DATA "MAN", "TELEPHONE","CLOWN","BASS", "GOLD", "RUBY", "CLEAN", "IMAGINE", "UMBRELLA","FLAT"
 DATA "SAIL", "JUST", "TRIAL", "PARTY", "PIN", "SOUP", "EAT", "SCHOOL", "ROCK", "PREDICT"
 DATA "ONE", "WASTE", "WORLD", "MORNING", "NIGHT", "MONKEY", "YESTERDAY","TIME", "FAKE", "SING"
 DATA "THROUGH","BUG", "TWO", "YOU", "MEN", "BELIEVE", "ENEMY", "NACHOS", "CHIP", "SUN"
 DATA "FAITH", "TIME", "FIFTY", "YEAR", "NURSE", "WHEEL", "BOY", "PRACTICE","PEST", "PAT"
 DATA "SIT", "STAND", "SANDWICH","LAMP", "DOZEN", "CART", "PROUD", "MAGIC", "SNOW", "BELT"
 DATA "SONG", "SELFISH","LOVE", "LOG", "TWIG", "POTATO", "DRIVE", "TOP", "MUG", "STOP"
 DATA "PIT", "TAN", "SAT", "PIANO" , "BOOM", "LISTEN", "REMEMBER","TOY", "MILK", "TORNADO"
 DATA "HAM", "PEANUT","MELON", "MOOSE", "WEASEL", "LONG", "COOL", "BLACK", "DRESS", "TARIFF"
 DATA "PIANO", "BEAUTIFUL","DIGITAL","MYSTERY","GHOST", "CUP", "HOUSE", "QUOTE", "VOLUME", "LOUD"
 DATA "BASKET", "BOWL", "PRETTY", "WOMAN", "MAN", "KIND", "TRUTH", "MERCY", "SUCH", "SHIRT"
 DATA "SILENT", "TONIGHT","WALK", "CRY", "AWAY", "HOME", "TOMORROW","BACK", "HORSE", "COLUMN"
 DATA "FOOT", "WASH", "PAIN", "RAIN", "SHAME", "SISTER", "HELP", "LUCKY", "ROAST", "ROAD"
 DATA "HALL", "NAIL", "PIG", "FLOWERS", "EYE", "SHOULDER","COOKIE", "CURRENT", "SHY", "KINGDOM"
 DATA "STATIC", "DYNAMIC","TWIST", "SHOUT", "MINUTE", "NIGHT", "MARCH", "WONDERFUL","MOTHER", "URBAN"
 DATA "MACHINE","RURAL", "ALMANAC", "ISLAND", "MUSTACHE", "COMPACT", "POTTERY", "MAP", "TIP", "EAR"
 DATA "BREAK", "TWILIGHT","WAS", "STRONG", "SURE", "OUT", "GROUND", "BIRD", "HOLD", "LEAF"
 DATA "HURT", "COMFORT","SUNSHINE","GIVE", "BEG", "DOCK", "SPELL", "NEVER", "GREEN", "BLOOD"
 DATA "BEEP", "KEY", "LONG", "HAPPY", "CAMERA", "DUCK", "CLOCK", "WIFE", "CITY", "EVENING"
 DATA "SHIP", "REPEAT", "TIDE", "GLASS", "FORK", "BUNNY", "CHEMISTRY","TIN", "BONE", "WASP"
 DATA "LODGE", "QUESTION","ALGEBRA","DAISY", "CANDY", "WEDDING", "GARDEN", "POLE", "MITTEN", "LIP"
 DATA "TRUCK", "COUNTY", "CHIN", "LIBRARY", "EQUIPMENT","HAMMER", "NEEDLE", "KNIFE", "MEMBER", "BOIL"
 DATA "BLACK", "IMMENSE", "BASS", "TENOR", "SEW", "PEOPLE", "RANGE", "SPACE", "ROBOT", "BRAG"
 DATA "MARGARINE","WISH", "FRUIT", "ABSTRACT","SHOW", "SCUM", "TOWN", "TIGER", "LION", "CLAW"
 DATA "FLOOR", "CAVE", "BEFORE", "ERASER", "LETTER", "CRUMB", "BOG", "GRAMMAR","SPORT", "KANGAROO"
 DATA "SLURP", "MESS", "TRADITION","WET", "CLUE", "CRAYON", "SURF", "MOUNTAIN","HILL", "SALT"
 DATA "PLANET", "WAVE", "TUNE", "MIX", "MURDER", "HEART", "GRIN", "WRITE", "OMEN", "SHEET"
 DATA "THANK", "MAKE", "CANOE", "TUB", "CLEAN", "PRESIDENT","KNEE", "PRETEND", "ROCK", "TRAVEL"
 DATA "GARAGE", "SMOKE", "FIRST", "SECOND", "MOST", "SENATOR", "COMIC", "LAUGH", "OPERATION","STOVE"
 DATA "STINK", "RIVER", "TRAIN", "PAGE", "PHYSICS", "GRUNT", "GASP", "PORK", "CLUTCH", "SCISSORS"
 DATA "JELLY", "FLUFF", "ODYSSEY","WORM", "GREASE", "JEOPARDY","GUILTY", "DIRECT", "DANCE", "SQUIRREL"
 DATA "DATA", "APRIL", "FLUTE", "VACATION","MONARCH", "BURGLAR", "CONE", "GUM", "SET", "OAK"
 DATA "PRETZEL","WALNUT", "WREATH", "UNCLE", "COUSIN", "AUTHOR", "ORCHESTRA","BET", "STITCH", "MAPLE"
 DATA "CRACKER","SOUP", "BAKERY", "TEACUP", "JOKE", "NOVEL", "CINEMA", "MOVIE", "THREAD", "WEAR"
 DATA "TENNIS", "GRASS", "HEX", "VOODOO", "SPECIAL", "COLLEGE", "BREAD", "SPICY", "MAGAZINE", "HAT" 
 DATA "SCORPION","MAROON", "DOPE", "KEY", "BUSH", "BORROW", "SCARLET", "MUSTARD", "PEACOCK", "WHITE"
 DATA "NAPKIN", "PLEDGE", "STEREO", "DIAMOND", "SIMMER", "OFFICE", "SOLDIER", "CORPORAL","PRISTINE", "BARITONE"
 DATA "ENGAGE", "ATTEMPT", "HAZARD", "MUSHROOM","PASTE", "GLUE", "HEN", "CRAZY", "HOT", "DESTROY"
 DATA "JOY", "CRAP", "LEG", "MOUTH", "FOOT", "FENCE", "ARRIVE", "ESCHEW", "CATTLE", "CORN"
 DATA "FERN", "POT", "WET", "SORT", "PANDA", "RAFT", "BOX", "FOX", "GET", "WIN"
 DATA "AMAZE", "DOT", "COMPLAIN","PET", "BLUE", "FISH", "SEE", "SIGHT", "DESK", "HANDLE"
 DATA "PLY", "GYPSY", "YESTERDAY","FLY", "DROP", "HURL", "SHELF", "ANGER", "SOLACE", "DESPAIR"
 DATA "BULB", "CASTLE", "OTHER", "APRON", "SPRING", "YAWN", "ZIPPER", "CONCERT", "CARPET", "WONDER"
 DATA "CAROUSEL","VILLAGE","CAP", "WHY", "JULY", "TEMPO", "TEXT", "SWIM", "DULL", "STICK"
 DATA "GLOBE", "POSTER", "REPAIR", "LEISURE","ATLAS", "HUNK", "PRELUDE", "SONATA", "JUSTICE", "SUPREME"
 DATA "STRANGE", "MUSICAL","ELEPHANT", "COCKROACH","YOKE", "PRESSURE","DEVIL", "VENOM", "INFINITY", "PIGEON"
 DATA "ADVENTURE","EXTRA", "NOWHERE", "PORTABLE", "ELICIT","IGNEOUS", "SEDIMENT", "MUD", "TAXI", "ANTENNA"
 DATA "SPECTRUM", "AND", "SQUARE", "ANGLE", "TUMBLE","BASSOON", "SWITCH", "MORE", "POP", "SHADE"
 DATA "TOILET", "GASOLINE","INK", "JET", "CABLE", "DRAW", "EYEBROW", "DIAL", "SIGN", "PURSUE"
 DATA "TORN", "FIX", "FINE", "WAR", "FIN", "BEND", "BIND", "BERRY", "TAR", "CHECK"
 DATA "MINIATURE","HOUSE", "FUN", "BED", "MAD", "GOT", "LEVEL", "EXPONENT","WON", "WIN"
 DATA "EAGER", "ALGEBRA", "PARK", "ICE", "IRE", "VAT", "MIST", "FORGET", "OIL", "FLOAT"
 DATA "DAM", "CHIPMONK","GUESS", "NIP", "GUY", "SMILE", "FRIEND", "ODD", "SHOP", "SERIOUS"
 DATA "RING", "TICK", "POPCORN", "PLEA", "PLAZA", "RAPID", "OPAQUE", "CHEDDAR", "HOPE", "NAP"
 DATA "SUBLIME", "RIDICULE","PAR", "SCAR", "WRINKLE","FICTION","POEM", "SIN", "ASK", "SNAP"
 DATA "CREDIT", "RHAPSODY","ETUDE", "APEX", "HUSTLE","FATHER", "SURPRISE", "COW", "BULL", "WINK"
 DATA "PERTAIN", "TORMENT", "EXCUSE", "FINGER", "SLOW", "SOUL", "RHYTHM", "MOTOR", "POCKET", "LARCENY"
 DATA "CHARM", "TROPICAL", "CHASE", "BENEFIT", "CROOKED","HOG", "TOURIST", "CLAN", "SICK", "INSECT"
 DATA "MARSUPIAL","ISTHMUS", "LITTLE", "ART", "BRUSH", "TOOTH", "CABINET", "ROOM", "SCARE", "OPINION"
 DATA "BETWEEN", "REAL", "GLORY", "GENTLE", "ASSUME", "SON", "TAKE", "GROOVE", "JEANS", "MILD"
 
 
 
 
 bgnd:
 'background
 DRAW "BM175,0 C44 R143 D102 L143 U102 BF5"
 DRAW "P44,44 BH5"
 DRAW "L170 D102 R170 U5 L165 U92 R165 BL1 BU1"
 DRAW "P44,44"
 
 'scaffold
 DRAW "C8 BM220,95"
 DRAW "R76 L20 U90 L30 D8 "
 RETURN
 
 drawboard:
 COLOR 198
 LOCATE 4, 6
 PRINT "A B C D E F G"
 LOCATE 6, 6
 PRINT "H I J K L M N"
 LOCATE 8, 6
 PRINT "O P Q R S T U"
 LOCATE 10, 6
 PRINT "V W X Y Z"
 COLOR 15
 RETURN
 
 
 ohno:
 CLS
 COLOR 15
 PRINT
 PRINT " AN ERROR HAS OCCURED."
 PRINT " PRESS ANY KEY TO LEAVE."
 SLEEP
 END
 
 SUB calculate
 SELECT CASE nwrong
 CASE 1
 CIRCLE STEP(0, 5), 10, 122, , , 1.5
 DRAW "P66,122"
 SLEEP
 EXIT SUB
 CASE 2
 CIRCLE STEP(0, 28), 18, 122, , , 1.9
 DRAW "P55,122"
 SLEEP
 EXIT SUB
 CASE 3
 DRAW "BD15 R6 C122"
 DRAW "D3 R1 D3 R1 D3 R1 D3 R1 D3 R1 D3 R1 D3 R1 G4 L1 U3 L1 U3 L1 U3 L1 U3 L1 U3 L1 U3 L1 U3 BR3"
 DRAW "P55,122 BL3 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD1"
 SLEEP
 EXIT SUB
 CASE 4
 DRAW "C200 E6 R1 F1 D1 G6 H2 BR1"
 DRAW "P200,200"
 SLEEP
 EXIT SUB
 CASE 5
 DRAW "BL16 BU27"
 DRAW "C122 G18 F4 E18 BL2 BG2"
 DRAW "P55,122 BE2 BR2 BG18 C200"
 SLEEP
 EXIT SUB
 CASE 6
 DRAW "H6 L1 G1 D1 F6 E2 BL2"
 DRAW "P200,200"
 SLEEP
 EXIT SUB
 CASE 7
 DRAW "BU49 BR17"
 DRAW "C122 G13 H10 E3 F7 E11 R3 BG4"
 DRAW "P55,122"
 SLEEP
 EXIT SUB
 CASE 8
 DRAW "BL17"
 DRAW "C122 U3 L1 G2 H4 G2 F6 E4 BG2 BL1"
 DRAW "P66,122 BR35 BD1"
 SLEEP
 EXIT SUB
 CASE 9
 DRAW "C122 R1 D4 R1 D5 R1 D4 R1 D4 R1 D3 R3 U3 L1 U4 L1 U4 L1 U5 L1 U4 L1 U5 L5 BR2 BD2"
 DRAW "P55,122"
 SLEEP
 EXIT SUB
 CASE 10
 DRAW "BR8 BD23"
 DRAW "C122 F2 D1 L2 D4 L3 U6 R5 BD1 BL2"
 DRAW "P66,122 BU41 BL9"
 SLEEP
 EXIT SUB
 CASE 11
 DRAW "C122 H1 L1 H2 L5 G1 L1 G1 L1 BE2 BR1"
 DRAW "P232,122"
 CIRCLE STEP(1, 5), 1, 232
 DRAW "P232,232"
 CIRCLE STEP(4, 0), 1, 232
 DRAW "P232,232"
 CIRCLE STEP(-2, 5), 1, 39
 CASE IS > 11: lost
 SLEEP
 END SELECT
 END SUB
 
 SUB ending
 LOCATE 21: PRINT " CORRECT! THE WORD WAS " + curword + ". "
 LINE (175, 0)-(310, 100), 44, BF
 DRAW "BM175,0 C44 R143 D102 L143 U102 BF5"
 DRAW "P44,44 BH5"
 DRAW "L170 D102 R170 U5 L165 U92 R165 BL1 BU1"
 DRAW "P44,44"
 DRAW "C8 BM220,95"
 DRAW "R76 L20 U90 L30 D8 "
 SLEEP 1
 PLAY "MNT200O3L4L2CL4D.L8CC.L16CL8C.L16CL4CL8E.L16DL8D.L16CL8C.L16CL2C"
 SLEEP
 END SUB
 
 SUB start
 SCREEN 13
 CLS
 
 bgnd2:
 'background
 DRAW "BM175,0 C44 R143 D102 L143 U102 BF5"
 DRAW "P44,44 BH5"
 DRAW "L170 D102 R170 U5 L165 U92 R165 BL1 BU1"
 DRAW "P44,44"
 DRAW "BD1 BR1 BD102"
 DRAW "C55 L170 D60 R313 U60 L143 BD5 L165 D50 R303 U50 L138 BU1"
 DRAW "P55,55"
 
 COLOR 36
 LOCATE 3, 6
 PRINT "HANGMAN"
 
 COLOR 37
 LOCATE 4, 7
 PRINT "HANGMAN"
 
 COLOR 38
 LOCATE 5, 8
 PRINT "HANGMAN"
 
 COLOR 39
 LOCATE 7, 6
 PRINT "H A N G M A N"
 
 COLOR 38
 LOCATE 9, 10
 PRINT "HANGMAN"
 
 COLOR 37
 LOCATE 10, 11
 PRINT "HANGMAN"
 
 COLOR 36
 LOCATE 11, 12
 PRINT "HANGMAN"
 
 COLOR 39
 LOCATE 23
 PRINT " H A N G M A N "
 
 'scaffold
 DRAW "C8 BM220,95"
 DRAW "R76 L20 U90 L30 D8 "
 
 'head
 CIRCLE STEP(0, 5), 10, 122, , , 1.5
 DRAW "P66,122"
 
 'body
 CIRCLE STEP(0, 28), 18, 122, , , 1.9
 DRAW "P55,122"
 
 'right leg
 DRAW "BD15 R6 C122"
 DRAW "D3 R1 D3 R1 D3 R1 D3 R1 D3 R1 D3 R1 D3 R1 G4 L1 U3 L1 U3 L1 U3 L1 U3 L1 U3 L1 U3 L1 U3 BR3"
 DRAW "P55,122 BL3 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD3 BR1 BD1"
 
 'RIGHT FOOT
 DRAW "C200 E6 R1 F1 D1 G6 H2 BR1"
 DRAW "P200,200"
 
 'left leg
 DRAW "BL16 BU27"
 DRAW "C122 G18 F4 E18 BL2 BG2"
 DRAW "P55,122 BE2 BR2 BG18 C200"
 
 'left foot
 DRAW "H6 L1 G1 D1 F6 E2 BL2"
 DRAW "P200,200"
 
 'left arm
 DRAW "BU49 BR17"
 DRAW "C122 G13 H10 E3 F7 E11 R3 BG4"
 DRAW "P55,122"
 
 'left hand
 DRAW "BL17"
 DRAW "C122 U3 L1 G2 H4 G2 F6 E4 BG2 BL1"
 DRAW "P66,122 BR35 BD1"
 
 'right arm
 DRAW "C122 R1 D4 R1 D5 R1 D4 R1 D4 R1 D3 R3 U3 L1 U4 L1 U4 L1 U5 L1 U4 L1 U5 L5 BR2 BD2"
 DRAW "P55,122"
 
 'right hand
 DRAW "BR8 BD23"
 DRAW "C122 F2 D1 L2 D4 L3 U6 R5 BD1 BL2"
 DRAW "P66,122 BU41 BL9"
 
 'features
 DRAW "C122 H1 L1 H2 L5 G1 L1 G1 L1 BE2 BR1"
 DRAW "P232,122"
 CIRCLE STEP(1, 5), 1, 232
 DRAW "P232,232"
 CIRCLE STEP(4, 0), 1, 232
 DRAW "P232,232"
 CIRCLE STEP(-2, 5), 1, 39
 
 COLOR 38
 LOCATE 16, 17
 PRINT "PRESS:"
 LOCATE 18, 4
 PRINT "1 TO PLAY THE GAME AND 2 TO QUIT"
 IF already = 0 THEN PLAY "MNT150L8O2AL4>DL8DDEFL4EL8DL4DL8DEFGAA+L2AP8L8AL4>D L8DDCDP8L8 95 AND SCREEN(18, 7) <> 95 AND SCREEN(18, 11) <> 95 AND SCREEN(18, 15) <> 95 AND SCREEN(18, 19) <> 95 AND SCREEN(18, 23) <> 95 AND SCREEN(18, 27) <> 95 AND SCREEN(18, 31) <> 95 AND SCREEN(18, 35) <> 95 AND SCREEN(18, 39) <> 95 _
 THEN test = 1
 END FUNCTION
 
 SUB tletter (wletter$)
 COLOR 39
 SELECT CASE wletter$
 CASE "A"
 LOCATE 4, 6
 PRINT "A"
 CASE "B"
 LOCATE 4, 8
 PRINT "B"
 CASE "C"
 LOCATE 4, 10
 PRINT "C"
 CASE "D"
 LOCATE 4, 12
 PRINT "D"
 CASE "E"
 LOCATE 4, 14
 PRINT "E"
 CASE "F"
 LOCATE 4, 16
 PRINT "F"
 CASE "G"
 LOCATE 4, 18
 PRINT "G"
 CASE "H"
 LOCATE 6, 6
 PRINT "H"
 CASE "I"
 LOCATE 6, 8
 PRINT "I"
 CASE "J"
 LOCATE 6, 10
 PRINT "J"
 CASE "K"
 LOCATE 6, 12
 PRINT "K"
 CASE "L"
 LOCATE 6, 14
 PRINT "L"
 CASE "M"
 LOCATE 6, 16
 PRINT "M"
 CASE "N"
 LOCATE 6, 18
 PRINT "N"
 CASE "O"
 LOCATE 8, 6
 PRINT "O"
 CASE "P"
 LOCATE 8, 8
 PRINT "P"
 CASE "Q"
 LOCATE 8, 10
 PRINT "Q"
 CASE "R"
 LOCATE 8, 12
 PRINT "R"
 CASE "S"
 LOCATE 8, 14
 PRINT "S"
 CASE "T"
 LOCATE 8, 16
 PRINT "T"
 CASE "U"
 LOCATE 8, 18
 PRINT "U"
 CASE "V"
 LOCATE 10, 6
 PRINT "V"
 CASE "W"
 LOCATE 10, 8
 PRINT "W"
 CASE "X"
 LOCATE 10, 10
 PRINT "X"
 CASE "Y"
 LOCATE 10, 12
 PRINT "Y"
 CASE "Z"
 LOCATE 10, 14
 PRINT "Z"
 END SELECT
 COLOR 15
 END SUB


Post a Comment

0 Comments