|
-
Dec 14th, 2004, 08:27 AM
#1
Thread Starter
New Member
craps dice games
hi all
I have to Write a Visual Basic Project to simulate a dice game known as ‘Craps’.
The rules of the game are
A player rolls two dice. Each die has six faces, These faces contain 1, 2, 3, 4, 5 and 6 spots.
The dice are rolled and after the dice have come to rest, the sum of the spots on the two upward faces is calculated.
If the sum on the first throw is 7 or 11 then the player wins.
If the sum on the first throw is 2 ("snake eyes"), 3 ("trey") or 12 ("boxcars") then the player loses (ie the house wins).
If the sum on the first throw is 4, 5, 6, 8, 9 or 10, then that sum becomes the player's "point".
To win in this case the player must continue rolling the dice until he makes his "point".
If the player rolls a 7 before he has made his point then he loses and the house wins.
how do i on the first throw when the sum = 4,5,6,8,9,10 get the sum to become the players point and continue rolling the dice unitl the player makes is point or if 7 is rolled during this time the player loses.
this is my code so far
Dim txt As Integer
Dim number As Integer
Dim number1 As Integer
Dim numbertotal As Integer
Dim RandomNum As Integer
Dim RandomNum2 As Integer
Private Sub point_Click()
End Sub
Private Sub play_Click()
roll.Visible = True
End Sub
Private Sub roll_Click()
Randomize Timer
RandomNum = Int(Rnd * 6) + 1
RandomNum2 = Int(Rnd * 6) + 1
Text1 = RandomNum
Text2 = RandomNum2
Select Case Text1
Case 1
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice1.bmp")
Case 2
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice2.bmp")
Case 3
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice3.bmp")
Case 4
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice4.bmp")
Case 5
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice5.bmp")
Case 6
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice6.bmp")
End Select
Select Case Text2
Case 1
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice1.bmp")
Case 2
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice2.bmp")
Case 3
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice3.bmp")
Case 4
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice4.bmp")
Case 5
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice5.bmp")
Case 6
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice6.bmp")
End Select
number = Text1
number1 = Text2
numbertotal = number + number1
Select Case numbertotal
Case 7, 11
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "You Win!"
roll.Visible = False
Case 2, 3, 12
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "You Lose"
roll.Visible = False
Case 4, 5, 6, 8, 9, 10
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "Roll Again!"
End Select
End Sub
any help would be greatley appreciated
john
-
Dec 14th, 2004, 09:10 AM
#2
Fanatic Member
Re: craps dice games
For a start you could reduce your code form this:
Code:
Select Case Text1
Case 1
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice1.bmp")
Case 2
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice2.bmp")
Case 3
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice3.bmp")
Case 4
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice4.bmp")
Case 5
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice5.bmp")
Case 6
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice6.bmp")
End Select
Select Case Text2
Case 1
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice1.bmp")
Case 2
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice2.bmp")
Case 3
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice3.bmp")
Case 4
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice4.bmp")
Case 5
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice5.bmp")
Case 6
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice6.bmp")
End Select
to this:
Code:
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice" & Text1 & ".bmp")
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice" & Text2 & ".bmp")
Also, when he throws a 9 for example his "point" becomes 9...what is he then looking to throw to win?
 Life is one big rock tune 
-
Dec 14th, 2004, 09:53 AM
#3
Fanatic Member
Re: craps dice games
I've tried to guess this based on rules I don't really understand but it should be enough for you to get going with, enjoy
Code:
Dim previousRoll As Integer
Private Sub Command1_Click()
Dim txt As Integer
Dim number As Integer
Dim number1 As Integer
Dim numbertotal As Integer
Dim RandomNum As Integer
Dim RandomNum2 As Integer
Randomize Timer
RandomNum = Int(Rnd * 6) + 1
RandomNum2 = Int(Rnd * 6) + 1
Text1 = RandomNum
Text2 = RandomNum2
dice1.Visible = True
dice1.Picture = LoadPicture("C:\university work\visual basic\craps\dice" & Text1 & ".bmp")
dice2.Visible = True
dice2.Picture = LoadPicture("C:\university work\visual basic\craps\dice" & Text2 & ".bmp")
number = Text1
number1 = Text2
numbertotal = number + number1
If previousRoll = 0 Then
Select Case numbertotal
Case 7, 11
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "You WIN!"
Case 2, 3, 12
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "You LOSE"
Case 4, 5, 6, 8, 9, 10
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "Roll Again!"
previousRoll = numbertotal
End Select
Else
Select Case numbertotal
Case 7
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "You LOSE"
previousRoll = 0
Case 4, 5, 6, 8, 9, 10
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "You WIN"
previousRoll = 0
Case Else
total.Caption = "Your Point is" & Space(1) & numbertotal
info.Caption = "Roll Again!"
previousRoll = numbertotal
End Select
End If
End Sub
Private Sub Form_Load()
previousRoll = 0
End Sub
 Life is one big rock tune 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|