cfreiling
Nov 29th, 2000, 12:13 AM
Las Vegas Craps Style Game. Simple class project? I've looked Up and Down left to right, back and forth and asked a few classmates but they dont understand why My game does not work. I have the problem here:
--------------------------------------------------
'Calls Function to Roll Dice
Private Function RollDice() As Integer
Dim Die1 As Integer, Die2 As Integer, DieSum As Integer
Dim a As Integer, b As Integer
Die1 = 1 + Int(6 * Rnd()) 'Roll Die1
Die2 = 1 + Int(6 * Rnd()) 'Roll Die2
Call DisplayDie(imgDie1, Die1) 'Draws die1 image
Call DisplayDie(imgDie2, Die2) '<---Have Problem Here.
mDie1 = Die1 'Stores die1 Value
mDie2 = Die2 'Stores die2 Value
DieSum = Die1 + Die2 'Sum Dice
RollDice = DieSum 'Returns die sum to caller
End Function
--------------------------------------------------
The problem is with Call DisplayDie(imgDie2, Die2).
If its not that it usually when:
-----------------
Private Sub DisplayDie(imgDie As Image, Face As Integer)
imgDie.Picture = ("F:\CIS-5\Ch06\images\die" & Face & ".gif")
End Sub
-----------------
When it calls for the picture(image) its generates a mismatch with the & after Face
I've applied the Full Code for the game below
----------FULL CODE-------------------------------
Option Explicit
Dim mMyPoint As Integer 'General Declaration
Dim mDie1 As Integer 'General Declaration
Dim mDie2 As Integer 'General Declaration
Const snakeEyes = 2 'Explicitly assign 2
Const Trey = 3 'Implicitly assign 3 (snakeEyes + 1)
Const yoleven = 11 'Explicitly assign 11
Const boxcars As Integer = 12 'Implicitly assign 12([yo leven])
Private Sub InitializizeGame(mintMyPoint As Integer)
mMyPoint = 0
fraPoint.Caption = "Point"
lblStatus.Caption = ""
imgPointDie1.Picture = LoadPicture("")
imgPointDie2.Picture = LoadPicture("")
End Sub
Private Sub cmdPlay_Click()
Dim sum As Integer
Call InitializizeGame(0)
'Initialization
Call Randomize
sum = RollDice() 'Invoke rolldice
'Detrimine outcome of first roll
Select Case sum
Case 7, [yoleven]
cmdRoll.Enabled = False 'Disable Roll button
lblStatus.Caption = "You Win!"
Case snakeEyes, Trey, boxcars
cmdRoll.Enabled = False
lblStatus.Caption = "Sorry, You Lose."
Case Else
mMyPoint = sum
fraPoint.Caption = "Point Is " & sum
lblStatus.Caption = "Roll Again."
Call DisplayDie(imgPointDie1, mDie1)
Call DisplayDie(imgPointDie2, mDie2)
cmdPlay.Enabled = False 'Disable Play Button
cmdRoll.Enabled = True 'Enable Roll Button
End Select
End Sub
Private Sub cmdRoll_Click()
Dim sum As Integer
sum = RollDice() 'Invoke rolldice
'Check For a win
If sum = mMyPoint Then 'Win
lblStatus.Caption = "You Win!!!"
cmdRoll.Enabled = False
cmdPlay.Enabled = True
ElseIf sum = 7 Then 'Lose
lblStatus.Caption = "Sorry, You Lose."
cmdRoll.Enabled = False
cmdPlay.Enabled = True
End If
End Sub
Private Sub DisplayDie(imgDie As Image, Face As Integer)
imgDie.Picture = ("F:\CIS-5\Ch06\images\die" & Face & ".gif")
End Sub
Private Function RollDice() As Integer
Dim Die1 As Integer, Die2 As Integer, DieSum As Integer
Dim a As Integer, b As Integer
Die1 = 1 + Int(6 * Rnd()) 'Roll Die1
Die2 = 1 + Int(6 * Rnd()) 'Roll Die2
Call DisplayDie(imgDie1, Die1) 'Draws die1 image
Call DisplayDie(imgDie2, Die2) 'Draws die2 image
mDie1 = Die1 'Stores die1 Value
mDie2 = Die2 'Stores die2 Value
DieSum = Die1 + Die2 'Sum Dice
RollDice = DieSum 'Returns die sum to caller
End Function
Private Sub Form_Load()
Icon = LoadPicture("F:\CIS-5\Ch06\images\die.ico")
End Sub
----------END CODE----------------------------------------
HELP IS WELCOME!!!!
Thanks
"Never Play Leap Frog with a Unicorn!"
--------------------------------------------------
'Calls Function to Roll Dice
Private Function RollDice() As Integer
Dim Die1 As Integer, Die2 As Integer, DieSum As Integer
Dim a As Integer, b As Integer
Die1 = 1 + Int(6 * Rnd()) 'Roll Die1
Die2 = 1 + Int(6 * Rnd()) 'Roll Die2
Call DisplayDie(imgDie1, Die1) 'Draws die1 image
Call DisplayDie(imgDie2, Die2) '<---Have Problem Here.
mDie1 = Die1 'Stores die1 Value
mDie2 = Die2 'Stores die2 Value
DieSum = Die1 + Die2 'Sum Dice
RollDice = DieSum 'Returns die sum to caller
End Function
--------------------------------------------------
The problem is with Call DisplayDie(imgDie2, Die2).
If its not that it usually when:
-----------------
Private Sub DisplayDie(imgDie As Image, Face As Integer)
imgDie.Picture = ("F:\CIS-5\Ch06\images\die" & Face & ".gif")
End Sub
-----------------
When it calls for the picture(image) its generates a mismatch with the & after Face
I've applied the Full Code for the game below
----------FULL CODE-------------------------------
Option Explicit
Dim mMyPoint As Integer 'General Declaration
Dim mDie1 As Integer 'General Declaration
Dim mDie2 As Integer 'General Declaration
Const snakeEyes = 2 'Explicitly assign 2
Const Trey = 3 'Implicitly assign 3 (snakeEyes + 1)
Const yoleven = 11 'Explicitly assign 11
Const boxcars As Integer = 12 'Implicitly assign 12([yo leven])
Private Sub InitializizeGame(mintMyPoint As Integer)
mMyPoint = 0
fraPoint.Caption = "Point"
lblStatus.Caption = ""
imgPointDie1.Picture = LoadPicture("")
imgPointDie2.Picture = LoadPicture("")
End Sub
Private Sub cmdPlay_Click()
Dim sum As Integer
Call InitializizeGame(0)
'Initialization
Call Randomize
sum = RollDice() 'Invoke rolldice
'Detrimine outcome of first roll
Select Case sum
Case 7, [yoleven]
cmdRoll.Enabled = False 'Disable Roll button
lblStatus.Caption = "You Win!"
Case snakeEyes, Trey, boxcars
cmdRoll.Enabled = False
lblStatus.Caption = "Sorry, You Lose."
Case Else
mMyPoint = sum
fraPoint.Caption = "Point Is " & sum
lblStatus.Caption = "Roll Again."
Call DisplayDie(imgPointDie1, mDie1)
Call DisplayDie(imgPointDie2, mDie2)
cmdPlay.Enabled = False 'Disable Play Button
cmdRoll.Enabled = True 'Enable Roll Button
End Select
End Sub
Private Sub cmdRoll_Click()
Dim sum As Integer
sum = RollDice() 'Invoke rolldice
'Check For a win
If sum = mMyPoint Then 'Win
lblStatus.Caption = "You Win!!!"
cmdRoll.Enabled = False
cmdPlay.Enabled = True
ElseIf sum = 7 Then 'Lose
lblStatus.Caption = "Sorry, You Lose."
cmdRoll.Enabled = False
cmdPlay.Enabled = True
End If
End Sub
Private Sub DisplayDie(imgDie As Image, Face As Integer)
imgDie.Picture = ("F:\CIS-5\Ch06\images\die" & Face & ".gif")
End Sub
Private Function RollDice() As Integer
Dim Die1 As Integer, Die2 As Integer, DieSum As Integer
Dim a As Integer, b As Integer
Die1 = 1 + Int(6 * Rnd()) 'Roll Die1
Die2 = 1 + Int(6 * Rnd()) 'Roll Die2
Call DisplayDie(imgDie1, Die1) 'Draws die1 image
Call DisplayDie(imgDie2, Die2) 'Draws die2 image
mDie1 = Die1 'Stores die1 Value
mDie2 = Die2 'Stores die2 Value
DieSum = Die1 + Die2 'Sum Dice
RollDice = DieSum 'Returns die sum to caller
End Function
Private Sub Form_Load()
Icon = LoadPicture("F:\CIS-5\Ch06\images\die.ico")
End Sub
----------END CODE----------------------------------------
HELP IS WELCOME!!!!
Thanks
"Never Play Leap Frog with a Unicorn!"