Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Yahtzee type game help


Yahtzee type game help

Author
Message
KnightFall
KnightFall
Forum God
Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)

Group: Forum Members
Posts: 2, Visits: 4
I've been creating Yahtzee, and I've basically been using If statements.  I figured out if I did If statements for a Small Straight, It would be about 1080 Statements...so I would like to know, is there anything to make this easier so I don't have to use the statements?
Mobius
Mobius
Forum God
Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)

Group: Forum Members
Posts: 632, Visits: 1K
Wow that's a lot of statements.

First off, I would condense them to ElseIf Statements. I'm making a Texas Hold 'Em application, or was until I started ASP proj's and I used a scoring system that incremented a counter variable for each match or good hand and then compared each counter variable.





-Mobius

waynespangler
waynespangler
Forum God
Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)Forum God (97K reputation)

Group: Forum Members
Posts: 910, Visits: 5.4K
You could put your 5 dice in an array, sort it small to large and then check if there is only one difference in each element of the array. If it is true then you have a 5 dice run.

Wayne

I know enough to be dangerious.

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.

Mobius
Mobius
Forum God
Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)

Group: Forum Members
Posts: 632, Visits: 1K
Yeah that would work. I'm a little rusty on Yahtzee. Can you get say 3 of a kind? You could increment a counter variable every time the program detects more than one type of number. Then the counter will reveal just how many more than one. I did this with my Hold 'Em app. It works fairly nicely.





-Mobius

Edited
2/24/2006 by Mobius
RoofRabbit
RoofRabbit
Forum God
Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)Forum God (5.2K reputation)

Group: Forum Members
Posts: 38, Visits: 23
Why not take a look at the source code for the Yahtzee game I made on my website.



http://roofrabbit.com/svbyahtzee.html



I have the game as a setup program or you can just download the source code. Either way, I've written it as freeware, enjoy.




Website: http://roofrabbit.com
KnightFall
KnightFall
Forum God
Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)

Group: Forum Members
Posts: 2, Visits: 4
Sub SelectBox_Click(Index As Integer)
    If PCPlayers(CurrentPlayer) = False Then If SelectBox(Index).BackStyle = 0 Then Exit Sub
    If Index < 6 Then
        Games(CurrentPlayer, Index) = HowManyThisDice(Index + 1) * (Index + 1)
        If Pref.SlotYahtzee > 0 Then If FindYahtzee = True Then AddYahtzee
        SlotUsed(CurrentPlayer, Index) = 1
        StartNewRoll
    Else
        Select Case Index

            Case 12 'Small Straight
                If Pref.SlotYahtzee > 0 Then If FindYahtzee = True Then AddYahtzee
                If FindStraight4 = True Then
                    Games(CurrentPlayer, GameSmallStraight) = 30
                Else
                    Games(CurrentPlayer, GameSmallStraight) = 0
                End If
                SlotUsed(CurrentPlayer, GameSmallStraight) = 1
                StartNewRoll
            Case 13 'Large Straight
                If Pref.SlotYahtzee > 0 Then If FindYahtzee = True Then AddYahtzee
                If FindStraight5 = True Then
                    Games(CurrentPlayer, GameLargeStraight) = 40
                Else
                    Games(CurrentPlayer, GameLargeStraight) = 0
                End If
                SlotUsed(CurrentPlayer, GameLargeStraight) = 1
                StartNewRoll

This is what I saw your project that was posted.  What I don't understand is where your FindStraight(put the number here) comes from.  I saw no other reference to it in the project........so ?

Keithuk
Keithuk
Forum God
Forum God (297K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K

There are quite a few control naming conventions that aren't followed and it doesn't play Babe.mid at all. Other than that its a nice yahtzee app. Wink

Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

istill316
istill316
Forum God
Forum God (48K reputation)Forum God (48K reputation)Forum God (48K reputation)Forum God (48K reputation)Forum God (48K reputation)Forum God (48K reputation)Forum God (48K reputation)Forum God (48K reputation)Forum God (48K reputation)

Group: Forum Members
Posts: 244, Visits: 23
Ooo!!! Yahtzee!!! I haven't played that in a long time, but I did make a VB5 version of it once. Maybe if I find it I can help you out... hehe.

I have to say, my version was awesome! The opening screen featured rolling dice and the song canyon.mid that came with Windows 95. What a great song! I don't know if I have ver found a cooler opening screen... hehe Tongue



Three Good Things

~ istill316


GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search