Psyber

Dice.bas v1.01

Nov 8th, 2018
823
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. REM Basic dice program v1.01, coded in qbasic 4.5
  2. REM v1 basic layout AND functions
  3. 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
  4.  
  5. RandomGenDice:
  6. REM Routine generates player's and computer's dice and print roll results
  7. CLS
  8. RANDOMIZE TIMER
  9. PRINT "Rolling Player's dice:"
  10. SLEEP 5
  11. A = INT((6 - 1 + 1) * RND + 1)
  12. B = INT((6 - 1 + 1) * RND + 1)
  13. PRINT "You rolled "; A; "and "; B
  14. PRINT "Rolling Computer's dice:"
  15. SLEEP 5
  16. C = INT((6 - 1 + 1) * RND + 1)
  17. D = INT((6 - 1 + 1) * RND + 1)
  18. PRINT "Computer rolled "; C; "and "; D
  19.  
  20. DiceTotalCompare:
  21. REM Find total FOR both player's and computer's rolls then compare them to determine if win/lose/draw
  22. F = A + B
  23. G = C + D
  24.  
  25. IF F > G THEN GOTO YWin
  26. IF F < G THEN GOTO YLose
  27. IF F = G THEN GOTO YDraw
  28.  
  29. Ywin:
  30. PRINT "You Win!"
  31. GOTO RollQuit
  32.  
  33. YLose:
  34. PRINT "You Lose!"
  35. GOTO RollQuit
  36.  
  37. YDraw:
  38. PRINT "It's a draw!"
  39. GOTO RollQuit
  40.  
  41. RollQuit:
  42. INPUT ; "Roll again?(y/n)"; reply$
  43. IF reply$ = "y" THEN
  44. GOTO RandomGenDice
  45. ELSE IF reply$ = "n" THEN END
  46. END IF
  47. GOTO RollQuit
RAW Paste Data