Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Cant get slot machine to keep respinning. It does one spin then exits.

Author
Message
michael_one
15
Years of Service
User Offline
Joined: 24th Dec 2010
Location:
Posted: 24th Dec 2010 09:28
`Assign ten dollars to the player's account
AccountBalance = 1000

CLS RGB(255, 0, 0) `Set background color to red
SET TEXT FONT "Arial" `Set the font type to Arial
SET TEXT SIZE 48 `Set the font size to 48 points
ForegroundColor = RGB(235, 235, 235) `Set foreground color to grey
BackgroundColor = RGB(235, 0, 0) `Set background color to red
INK ForegroundColor, BackgroundColor `Apply color settings
CENTER TEXT 320, 150, "Welcome to The" `Display welcome message
CENTER TEXT 320, 220, "Slot Machine Game"
SET TEXT SIZE 18 `Set the font size to 18 points
CENTER TEXT 320, 380, "Press any key to continue." `Display instructions
WAIT KEY `Pause game play until the player presses a keyboard key

CLS RGB(255, 0, 0) `Set background color to red
SET TEXT SIZE 24 `Set the font size to 24 points
TEXT 100, 120, "Instructions:"
TEXT 100, 160, "Press any key to place a bet."
TEXT 100, 190, "3 of a kind adds 200 dollars to your account"
TEXT 100, 220, "2 of a kind adds 100 dollars to your account"
TEXT 100, 250, "No matches subtracts 40 dollars from your account"
SET TEXT SIZE 18 `Set the font size to 18 points
CENTER TEXT 320, 380, "Press any key to continue" `Display instructions
WAIT KEY `Pause game play until the player presses a keyboard key

DO `Loop forever

FOR i = 1 TO 19 `Iterate nineteen times
ForegroundColor = RGB(235, 235, 235) `Set foreground color to grey
BackgroundColor = RGB(235, 0, 0) `Set background color to red
INK ForegroundColor, BackgroundColor `Apply color settings
CLS RGB(255, 0, 0) `Set background color to red
SET TEXT SIZE 36 `Set the font size to 36 points
CENTER TEXT 320, 90, "___________________________"
SET TEXT SIZE 72 `Set the font size to 72 points
`Display random numbers representing slot machines dials
CENTER TEXT 320, 150, STR$(RND(2) + 1) + " " + STR$(RND(2) + 1) + " " + STR$(RND(2) + 1)
SET TEXT SIZE 36 `Set the font size to 36 points
CENTER TEXT 320, 210, "___________________________"
SLEEP 200 `Pause game execution for a fifth of a second
NEXT


SET TEXT SIZE 72 `Set the font size to 72 points
CLS RGB(235, 0, 0) `Set background color to red
`Generate the final set of numbers representing dial values
DialOne = RND(2) + 1
DialTwo = RND(2) + 1
DialThree = RND(2) + 1
SET TEXT SIZE 36 `Set the font size to 36 points
CENTER TEXT 320, 90, "___________________________"
SET TEXT SIZE 72 `Set the font size to 72 points
`Display random numbers representing slot machine dials
CENTER TEXT 320, 150, STR$(DialOne) + " " + STR$(DialTwo) + " " + STR$(DialThree)
SET TEXT SIZE 36 `Set the font size to 36 points
CENTER TEXT 320, 210, "___________________________"

`Add up the final result for each dial
Result = DialOne + DialTwo + DialThree
SET TEXT SIZE 36 `Set the font size to 36 points
`Look for a jackpot made up of 3 ones or 3 threes
IF (Result = 3) OR (Result = 9)
CENTER TEXT 320, 260, "Three of a kind - Jackpot!"
'Add 200 dollars to the player's account
AccountBalance = AccountBalance + 200
ENDIF
IF Result = 6 `Look for a jackpot made up of 3 twos
IF DialOne = DialTwo 'There are 3 twos
CENTER TEXT 320, 260, "Three of a kind - Jackpot!"
`Add 2 dollars to the player's account
AccountBalance = AccountBalance + 200
ELSE `Look to see if a one, two, and three were generated
CENTER TEXT 320, 260, "No matches - You Lose!"
`Subtract 3 dollars from the player's account
AccountBalance = AccountBalance - 40
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!"
`Add 1 dollar to the player's account
AccountBalance = AccountBalance + 100
ENDIF

SET TEXT SIZE 24 `Set the font size to 24 points
`Display the player account balance
TEXT 75, 30, "Account Balance: " + STR$(AccountBalance)
SET TEXT SIZE 18 `Set the font size to 18 points
`Display instructions for continuing
CENTER TEXT 320, 420, "Press Escape to quit or any other key to continue."

`End game play if the player has gone broke
IF AccountBalance <= 0
SET TEXT SIZE 24 `Set the font size to 36 points
ForegroundColor = RGB(235, 235, 235) `Set foreground color to grey
BackgroundColor = RGB(235, 0, 0) `Set background color to red
INK ForegroundColor, BackgroundColor `Apply color settings
`Notify the player that the game is over
CENTER TEXT 320, 310, "G A M E O V E R"
CENTER TEXT 320, 350, "You have gone broke!"
WAIT KEY `Pause game play until the player presses a keyboard key
EXIT `Terminate the loop
ENDIF
WAIT KEY `Pause game play until the player presses a keyboard key

CLS RGB(235, 0, 0) `Set background color to red
ForegroundColor = RGB(235, 235, 235) `Set foreground color to grey
INK ForegroundColor, BackgroundColor `Apply color settings
SET TEXT SIZE 24 `Set the font size to 24 points
`Display the game's closing message
CENTER TEXT 320, 150, "Thanks for playing the Slot Machine Game!"
SET TEXT SIZE 16 `Set the font size to 24 points
CENTER TEXT 320, 240, "Developed by Michael Nechovski."
CENTER TEXT 320, 260, "Copyright 2010"
CENTER TEXT 320, 280, "[email protected]"
SET TEXT SIZE 18 `Set the font size to 16 points
CENTER TEXT 320, 380, "Press any key to end game."
WAIT KEY `Pause game play until the player presses a keyboard key
END `End the game

sync
loop
end
Jeff Miller
21
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 24th Dec 2010 14:05
Remove the "END" statement at line 121 (the END statement that is within the main loop).

Login to post a reply

Server time is: 2026-07-21 20:35:27
Your offset time is: 2026-07-21 20:35:27