SlotMachine by Anonymous Coder8th Apr 2012 15:49
|
---|
Summary A simple slot machine with 3 dials each with 7 outcomes. It repeats in an endless loop so the program doesn't automatically terminate. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com REM Project: Geometry Slot Machine Interactive REM Created: REM REM ***** Main Source File ***** REM load sound "PacmanSiren.wav", 1 load music "PacmanDie.mp3", 1 load music "PacmanEatGhost.mp3", 2 load music "PacmanOpening.mp3", 3 load music "PacmanEatCherry.mp3", 4 load music "PacmanIntermission.mp3", 5 do AccountBalance = 10 cls rgb(255, 255, 255) set text font "Arial" set text size 48 ForegroundColor = RGB(10, 20, 255) BackgroundColor = RGB(255, 255, 255) ink ForegroundColor, BackgroundColor `repeat `set text size 30 `center text 320, 240, "Press enter for sound and backspace for no sound" `if (inkey$() = chr$(12)) ` Sound = true `endif `if (inkey$() = chr$(8)) ` Sound = false `endif `until ((inkey$() = chr$(12)) or (inkey$() = chr$(8))) cls rgb(255, 255, 255) set text size 18 ForegroundColor = RGB(255, 0, 0) ink ForegroundColor, BackgroundColor print " Made with Darkbasic Proffesional" ForegroundColor = RGB(10, 20, 255) ink ForegroundColor, BackgroundColor set text size 48 Center text 320, 150, "Welcome to The" Center text 320, 220, "Slot Machine Madness" Set text size 24 Center Text 320, 290, "By: Michael Canniffe, Adam Kohli, and Kevin Hou" set text size 18 ForegroundColor = RGB (255, 0, 0) ink ForegroundColor, BackgroundColor center text 320, 380, "Press any key to continue" ForegroundColor = RGB(10, 20, 255) ink ForegroundColor, BackgroundColor wait key `if Sound = false ` set sound volume 1, 0 ` set music volume 1, 0 ` set music volume 2, 0 ` set music volume 3, 0 ` set music volume 4, 0 ` set music volume 5, 0 `else ` set sound volume 1, 100 ` set music volume 1, 100 ` set music volume 2, 100 ` set music volume 3, 100 ` set music volume 4, 100 ` set music volume 5, 100 `endif play music 4 cls rgb(255, 255, 255) set text size 48 Center text 320, 150, "Family Math Night" Center text 320, 220, "2012" set text size 18 ForegroundColor = RGB (255, 0, 0) ink ForegroundColor, BackgroundColor Center text 320, 380, "Press any key to continue" ForegroundColor = RGB(10, 20, 255) ink ForegroundColor, BackgroundColor wait key cls rgb(255, 255, 255) play music 3 set text size 24 text 100, 120, "Instructions:" text 100, 190, "3 of a kind adds 3 dollars to your account" text 100, 220, "2 of a kind adds 2 dollar to your account" text 100, 250, "No matches subtracts 3 dollars from your account" text 100, 280, "You have $" + STR$(AccountBalance) + " in your account." text 100, 310, "Press the space bar to stop the numbers. Good luck!" set text size 18 ForegroundColor = RGB (255, 0, 0) ink ForegroundColor, BackgroundColor center text 320, 380, "Press any key to continue" ForegroundColor = RGB(10, 20, 255) ink ForegroundColor, BackgroundColor wait key stop music 3 loop sound 1 do repeat `for i=1 to RND(39)+1 ` if (RND(3) <= 15 or RND(3) >= 30) ` RND(3) = RND(3) ` else ForegroundColor = RGB(0, 0, 160) BackgroundColor = RGB(255, 255, 255) Ink ForegroundColor, BackgroundColor cls RGB(255, 255, 255) stop music 1 stop music 2 set text size 18 center text 320, 250, "You have $" + STR$(AccountBalance) + " in your account." set text size 36 center text 320, 90, "__________________________" set text size 72 ellipse 320, 175, 300, 150 center text 320, 150, str$(RND(6)+1)+ " " + STR$(RND(6) + 1) + " " + STR$(RND(6) + 1) set text size 36 center text 320, 210, "__________________________" center text 320, 380, "Press the space bar to lock in the numbers" sleep 100 `Pause game for 1/5 of a second `endif `next until (INKEY$() = CHR$(32)) set text size 72 cls RGB(255, 255, 255) `Generate the final set of numbers representing dial values DialOne = RND(6) + 1 DialTwo = RND(6) + 1 DialThree = RND(6) + 1 set text size 36 center text 320, 90, "__________________________" set text size 72 center text 320, 150, STR$(DialOne) + " " + STR$(DialTwo) + " " + STR$(DialThree) set text size 36 center text 320, 210, "__________________________" `Add up the final result for each dial Result = DialOne + DialTwo + DialThree set text size 36 if (DialOne = DialTwo) and (DialTwo = DialThree) and (DialThree = DialOne) DialMatches = 3 endif if (DialOne = DialTwo) and (DialOne <> DialThree) and (DialTwo <> DialThree) DialMatches = 2 `endif endif if (DialOne = DialThree) and (DialOne <> DialTwo) and (DialThree <> DialTwo) DialMatches = 2 endif if (DialTwo = DialThree) and (DialTwo <> DialOne) and (DialThree <> DialOne) DialMatches = 2 endif if (DialOne <> DialTwo) and (DialOne <> DialThree) and (DialTwo <> DialThree) DialMatches = 0 endif `look for a jackpot made up of 3 ones or 3 threes if (DialMatches = 3) stop sound 1 play music 2 center text 320, 260, "Three of a kind - Jackpot!" `Add 2 dollars to the player's account AccountBalance = AccountBalance + 3 endif if (DialMatches = 2) stop sound 1 play music 2 center text 320, 260, "Two of a kind - Winner!" AccountBalance = AccountBalance + 2 endif `if (DialMatches = 0) ` ForegroundColor = rgb(160, 0, 0) ` INK ForegroundColor, BackgroundColor ` center text 320, 273, "No matches - You lose!" ` ForegroundColor = rgb(0, 0, 160) ` INK ForegroundColor, BackgroundColor ` AccountBalance = AccountBalance - 3 if (DialMatches = 0) stop sound 1 play music 1 ForegroundColor = rgb(160, 0, 0) INK ForegroundColor, BackgroundColor center text 320, 273, "No matches - You lose!" ForegroundColor = rgb(0, 0, 160) INK ForegroundColor, BackgroundColor AccountBalance = AccountBalance - 3 endif `if Result = 6 ` if DialOne = DialTwo ` Center Text 320, 260, "Three of a kind - Jackpot!" ` AccountBalance = AccountBalance + 2 ` ` else ` ForegroundColor = rgb(160, 0, 0) ` INK ForegroundColor, BackgroundColor ` center text 320, 273, "No matches - You lose!" ` ForegroundColor = rgb(0, 0, 160) ` INK ForegroundColor, BackgroundColor ` AccountBalance = AccountBalance - 3 ` endif `endif `Anything other than 3, 6, or 9 means a pair was generated `if (Result <> 3) and (Result <> 6) AND (Result <> 9) ` center text 320, 260, "Two of a kind - Winner!" ` AccountBalance = AccountBalance + 1 `endif set text size 24 text 75, 20, "Account Balance: "+ STR$(AccountBalance) set text size 18 Center text 320, 420, "Press Escape to quit or any other key to continue" if AccountBalance <=0 play music 5 ForgeroundColor = rgb(0, 0, 160) BackgroundColor = rgb(0, 0, 0) INK ForegroundColor, BackgroundColor Center text 320, 310, "G A M E O V E R" center text 320, 250, "You have gone broke!" set text size 28 ForegroundColor = rgb(160, 0, 0) INK ForegroundColor, BackgroundColor center text 320, 370, "THIS IS WHY YOU DON'T GAMBLE!" ForegroundColor = rgb(0, 0, 160) INK ForegroundColor, BackgroundColor wait key pause music 5 exit endif wait key loop sound 1 loop cls rgb(255, 255, 255) ForegroundColor = rgb(0, 0, 160) INK ForegroundColor, BackgroundColor set text size 30 resume music 5 center text 320, 150, "Thanks for playing the Slot Machine Game!" set text size 24 center text 320, 240, "Enjoy the rest of Family Math Night" set text size 18 center text 320, 380, "Press any key to end the game." stop music 5 wait key loop |