Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM Basic dice program v1.01, coded in qbasic 4.5
- REM v1 basic layout AND functions
- REM v1.01 moved player AND cpu dice gen TO before each roll AND placed a SLEEP TIMER TO give time FOR microPK TO be used before each players dice are generated
- RandomGenDice:
- REM Routine generates player's and computer's dice and print roll results
- CLS
- RANDOMIZE TIMER
- PRINT "Rolling Player's dice:"
- SLEEP 5
- A = INT((6 - 1 + 1) * RND + 1)
- B = INT((6 - 1 + 1) * RND + 1)
- PRINT "You rolled "; A; "and "; B
- PRINT "Rolling Computer's dice:"
- SLEEP 5
- C = INT((6 - 1 + 1) * RND + 1)
- D = INT((6 - 1 + 1) * RND + 1)
- PRINT "Computer rolled "; C; "and "; D
- DiceTotalCompare:
- REM Find total FOR both player's and computer's rolls then compare them to determine if win/lose/draw
- F = A + B
- G = C + D
- IF F > G THEN GOTO YWin
- IF F < G THEN GOTO YLose
- IF F = G THEN GOTO YDraw
- Ywin:
- PRINT "You Win!"
- GOTO RollQuit
- YLose:
- PRINT "You Lose!"
- GOTO RollQuit
- YDraw:
- PRINT "It's a draw!"
- GOTO RollQuit
- RollQuit:
- INPUT ; "Roll again?(y/n)"; reply$
- IF reply$ = "y" THEN
- GOTO RandomGenDice
- ELSE IF reply$ = "n" THEN END
- END IF
- GOTO RollQuit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement