DiceGame betting
DiceGame betting
DiceGame betting
DiceGame betting
DiceGame betting
DiceGame betting DiceGame betting DiceGame betting DiceGame betting DiceGame betting DiceGame betting DiceGame betting DiceGame betting
DiceGame betting DiceGame betting
DiceGame betting
Go Back  Xtreme Visual Basic Talk > > > DiceGame betting


Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2010, 07:26 AM
almost skater almost skater is offline
Newcomer
 
Join Date: Feb 2010
Posts: 3
Default DiceGame betting


i have been looking for forever to try and find a solutions so i can set up my betting system on my dicewar game. I'm not quite sure what textboxs or buttons to use for it. but i think that i have an idea. As you can tell im fairly new at this. but if you could help me it would be greatly appreciated. thank you

The picture of how the interactive is set up is attached if you need it.

heres my code
Code:
Public Class Form1 Dim player As Integer = 1 Dim round As Integer = 1 Dim roll1 As Integer = 1 Dim roll2 As Integer = 3 Dim rolls As Integer Dim score1 As Integer Dim score2 As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'initialize the random number generator Randomize() 'draw initial dice images pb1.Image = die6.Image pb2.Image = die6.Image If score1 > score2 Then dicenumber.Text = Val(bet.Text) * Val(36) + Val(dicenumber.Text) ElseIf score1 < score2 Then dicenumber.Text = Val(dicenumber.Text) - (Val(bet.Text) * Val(36)) End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'this event handles restart as well as roll If Button1.Text = "Restart" Then RestartGame() Else 'disable roll Button1.Enabled = False 'start roll timer1.enabled = True End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick rolldie1() rolldie2() 'increment roll counter rolls += 1 If RollOver() Then rolls = 0 Timer1.Enabled = False Button1.Enabled = True DisplayRoll(player) If GameOver() Then Button1.Text = "Restart" ShowWinner() Else Label5.Text = "Round " & round End If End If End Sub Private Sub restartgame() 'reset game Button1.Text = "Player 1 - Roll" score1 = 0 score2 = 0 Label4.Text = "Score: " & score1 Label3.Text = "Score: " & score2 round = 1 Label5.Text = "Round " & round pb1.Image = die6.Image pb2.Image = die6.Image End Sub Private Sub rolldie1() 'random roll for die1 roll1 = Int(Rnd() * 6) + 1 'display Select Case roll1 Case 1 pb1.Image = die1.Image Case 2 pb1.Image = die2.Image Case 3 pb1.Image = die3.Image Case 4 pb1.Image = die4.Image Case 5 pb1.Image = die5.Image Case 6 pb1.Image = die6.Image End Select End Sub Private Sub rolldie2() roll2 = Int(Rnd() * 6) + 1 Select Case roll2 Case 1 pb2.Image = die1.Image Case 2 pb2.Image = die2.Image Case 3 pb2.Image = die3.Image Case 4 pb2.Image = die4.Image Case 5 pb2.Image = die5.Image Case 6 pb2.Image = die6.Image End Select End Sub Private Function rollover() As Boolean If rolls > 30 Then rollover = True Else rollover = False End If End Function Private Sub displayroll(ByVal playernum As Integer) 'display total roll message depending on player Select Case playernum Case 1 MsgBox("Player 1, you rolled a " & Int(roll1 + roll2) & ".") score1 += roll1 + roll2 Label4.Text = "Score: " & score1 Button1.Text = "Player 2 - Roll" player = 2 Case 2 MsgBox("Player 2, you rolled a " & Int(roll1 + roll2) & ".") score2 += roll1 + roll2 Label3.Text = "Score: " & score2 Button1.Text = "Player 1 - Roll" player = 1 round += 1 Case Else MsgBox("PlaerNum is invalid") End Select End Sub Private Function GameOver() As Boolean If round > 3 Then GameOver = True Else GameOver = False End If End Function Private Sub showwinner() If score1 = score2 Then MsgBox("This game is a draw!") ElseIf score1 > score2 Then MsgBox("Player 1 is the winner!") ElseIf score2 > score1 Then MsgBox("Player 2 is the winner!") End If End Sub End Class
Attached Images
File Type: jpg dicewar.jpg (35.6 KB, 11 views)

Last edited by passel; 02-19-2010 at 10:39 AM. Reason: Added vbcode tags
Reply With Quote
  #2  
Old 02-09-2010, 05:27 AM
almost skater almost skater is offline
Newcomer
 
Join Date: Feb 2010
Posts: 3
Default

^ ^ ^ BUMP ^ ^ ^

hellooooo, anybody there?
Reply With Quote
  #3  
Old 02-09-2010, 07:14 AM
Qua's Avatar
QuaDiceGame betting Qua is offline
Impetuous & volatile

* Expert *
 
Join Date: Apr 2005
Posts: 2,177
Default

What have you tried so far and where did you get stuck? You haven't really described what you're trying to accomplish except for creating a sort of dice game.

Generally as a good tip: You don't get many answers by just posting a lot of code that aren't formatted, described or containing any comments. When you ask a question let us know what you've tried so far, and where you got stuck. That way we can easily pin-point where in the code you went wrong and should focus your attention.

Also, embrace your code segments in posts by [*code*][*/code*]-tags without the asterisks like this:
Code:
Private Sub showwinner()
 If score1 = score2 Then
  MsgBox("This game is a draw!")
 ElseIf score1 > score2 Then
  MsgBox("Player 1 is the winner!")
 ElseIf score2 > score1 Then
  MsgBox("Player 2 is the winner!")
 End If
End Sub
It makes the code a whole lot more readable
__________________
Reading is the foundation for all knowledge - Unknown.
Reply With Quote
  #4  
Old 02-09-2010, 07:38 AM
almost skater almost skater is offline
Newcomer
 
Join Date: Feb 2010
Posts: 3
Default

I'm trying to set up a betting system for my dice program.
basically what the program is that there are 2 players, whoever has the highest dice roll wins, the score accumulates after every round. and after 3 rounds the person with the highest score wins.

I want this to work so i can bet pretend $$ on a player out of 3 rounds and if i win then i get double my money if i loose i go in the hole. seems simple

this is what i tried and i have no idea where to go from here
Code:
If score1 > score2 Then
dicenumber.Text = Val(bet.Text) * Val(36) + Val(dicenumber.Text)
ElseIf score1 < score2 Then
dicenumber.Text = Val(dicenumber.Text) - (Val(bet.Text) * Val(36))
End If
Reply With Quote
  #5  
Old 02-09-2010, 09:14 AM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

What is this Val(36) for? Is this an overload of the Val() function? Does it return the value 36?

Why would you multiply the bet by 36, and why would you add or subtract that to or from the dice number?

Normally in betting games, players have a bankroll or a stake which is just the sum of all of their cash. Players decide how much they want to bet or wager on the outcome of a game or event.

When they lose, they lose an amount equal to the wager, but when they win they win an amount equal to the wager multiplied by the odds that wager pays for that outcome (for example, in the dice game of craps, some wagers pay 1:1, some pay 2:1, some pay 3:2, and some pay 6:5)
Reply With Quote
  #6  
Old 02-23-2010, 08:56 PM
gabychan gabychan is offline
Newcomer
 
Join Date: Feb 2010
Posts: 1
Default

Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
DiceGame betting
DiceGame betting
DiceGame betting DiceGame betting
DiceGame betting
DiceGame betting
DiceGame betting DiceGame betting DiceGame betting DiceGame betting DiceGame betting DiceGame betting DiceGame betting
DiceGame betting
DiceGame betting
 
DiceGame betting
DiceGame betting
 
-->