Computer Science Canada

My Slot Machine Program

Author:  Scooter341 [ Tue Apr 12, 2005 12:58 pm ]
Post subject:  My Slot Machine Program

Heres my slot Machine program that I am using for my final project in my compsci class. Its not much but I think it's pretty good for my first useful program.


EDIT (April 19th)
-------
Fixed:
-------
Betting bugs
Changed winnings
Added buttons
Made Instructions

Author:  jamonathin [ Tue Apr 12, 2005 2:38 pm ]
Post subject: 

Not bad, you should tell people to turn their volume down before running [very piercing]. You should also add in one quick if statement after you get their "coinage"
code:

if bid > coinage then
bid:=coinage
end if

Because your setup gets messed up if they're over, and just exit when there coins are = 0.
You should also award maybe half of their "coinage" back if they get 2/3. And, I got 1/2/3 and it said I won, but with false coinage? Confused
Not a bad start though, keep it up.

Author:  RscMod [ Wed Apr 13, 2005 8:46 am ]
Post subject: 

var die1, die2, die3, die4, playertotal, computertotal, bet, total :int
var answer:string
randint (die1,1,6)
randint (die2,1,6)
randint (die3,1,6)
randint (die4,1,6)
total:=0
procedure intro

put "Welcome to the dice game this game is where you can bet money on the rolls of dice"
end intro

procedure wager
put "This is where u bet money on ur dice"
put "How much would you like to bet?"
get bet
put " You just wagerd $" ,bet, " on the roll of the dice"
end wager

procedure player
if die1 = 1 then
Pic.ScreenLoad ("Die1.jpg", 200, 200, 0)
elsif die1 = 2 then
Pic.ScreenLoad ("Die2.jpg", 200, 200, 0)
elsif die1 = 3 then
Pic.ScreenLoad ("Die3.jpg", 200, 200, 0)
elsif die1 = 4 then
Pic.ScreenLoad ("Die4.jpg", 200, 200, 0)
elsif die1 = 5 then
Pic.ScreenLoad ("Die5.jpg", 200, 200, 0)
else
Pic.ScreenLoad ("Die6.jpg", 200, 200, 0)
end if
if die2 = 1 then
Pic.ScreenLoad ("Die1.jpg", 350, 200, 0)
elsif die2 = 2 then
Pic.ScreenLoad ("Die2.jpg", 350, 200, 0)
elsif die2 = 3 then
Pic.ScreenLoad ("Die3.jpg", 350, 200, 0)
elsif die2 = 4 then
Pic.ScreenLoad ("Die4.jpg", 350, 200, 0)
elsif die2 = 5 then
Pic.ScreenLoad ("Die5.jpg", 350, 200, 0)
else
Pic.ScreenLoad ("Die6.jpg", 350, 200, 0)
end if
end player
cls
procedure comp
if die3 = 1 then
Pic.ScreenLoad ("Die1.jpg", 200, 200, 0)
elsif die3 = 2 then
Pic.ScreenLoad ("Die2.jpg", 200, 200, 0)
elsif die3 = 3 then
Pic.ScreenLoad ("Die3.jpg", 200, 200, 0)
elsif die3 = 4 then
Pic.ScreenLoad ("Die4.jpg", 200, 200, 0)
elsif die3 = 5 then
Pic.ScreenLoad ("Die5.jpg", 200, 200, 0)
else
Pic.ScreenLoad ("Die6.jpg", 200, 200, 0)
end if
if die4 = 1 then
Pic.ScreenLoad ("Die1.jpg", 350, 200, 0)
elsif die4 = 2 then
Pic.ScreenLoad ("Die2.jpg", 350, 200, 0)
elsif die4 = 3 then
Pic.ScreenLoad ("Die3.jpg", 350, 200, 0)
elsif die4 = 4 then
Pic.ScreenLoad ("Die4.jpg", 350, 200, 0)
elsif die4 = 5 then
Pic.ScreenLoad ("Die5.jpg", 350, 200, 0)
else
Pic.ScreenLoad ("Die6.jpg", 350, 200, 0)
end if
end comp
total:=0
loop
randomize
randint (die1,1,6)
randint (die2,1,6)
randint (die3,1,6)
randint (die4,1,6)
intro
wager
delay (2000)
player
delay(2000)
playertotal := die1 + die2
computertotal := die3 + die4
put "the dice landed on a ", die1, " and a ", die2
put "that gives you a total of ", playertotal
delay (2000)
put "the computer rolls..............."
comp
put "the dice landed on a ", die3, " and a ", die4
put "that give the computer a total of ", computertotal
if playertotal > computertotal then
put "you won comgratz"
total :=total+ (bet)
elsif playertotal < computertotal then
put "you lose try again"
total:=total- (bet)
else
put "you tied the computer try again"
end if
delay (3000)
cls
put "you have a bank roll of $" , total
put "would you like to play again?"
get answer
exit when answer = "hell no"
end loop
cls
put "game over"

Author:  jamonathin [ Wed Apr 13, 2005 8:55 am ]
Post subject: 

Few things:
code:
[code]*PUT CODE HERE*[/code]
another thing, your wagers are a little messed up. There's no real point to the bank roll. I can bid whatever, lose whatever, and then bid whatever+1, or even -whatever. It's a nice little start, just work on the bidding and it should be fine. Also, fix your typos Wink

p.s. Learn arrays next.

Author:  RscMod [ Wed Apr 13, 2005 9:04 am ]
Post subject: 

jamonathin wrote:
Few things:
code:
[code]*PUT CODE HERE*[/code]
another thing, your wagers are a little messed up. There's no real point to the bank roll. I can bid whatever, lose whatever, and then bid whatever+1, or even -whatever. It's a nice little start, just work on the bidding and it should be fine. Also, fix your typos Wink

p.s. Learn arrays next.


ok thanks


: