Results 1 to 2 of 2

Thread: Creating player turns

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2009
    Posts
    16

    Creating player turns

    Hi,

    Another newbie question i am afraid, I have created a game of pontoon it generates the numbers into an array and the assigns the values to the labels. this all works great.

    however the bit that i am stuck on is creating a player turn as each label has a name lnlP1Card1 to lblP1Card5 for player 1 and lblP2Card1 -5 for player 2 etc. I tried to create a set of if statements that checked a counter and then if the counters value matched the if statement the players turn moved to the next player. sample code:

    If pcount < 5 Then
    Do
    If pcount = 1 Then
    twist()
    lblP1Card3.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 2 Then
    twist()
    lblP2Card3.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 3 Then
    twist()
    lblP3Card3.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 4 Then
    twist()
    lblP4Card3.Text = rand
    pcount += 1
    Exit Do
    End If
    Loop
    ElseIf pcount > 4 < 9 Then
    Do
    If pcount = 5 Then
    twist()
    lblP1Card4.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 6 Then
    twist()
    lblP2Card4.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 7 Then
    twist()
    lblP3Card4.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 8 Then
    twist()
    lblP4Card4.Text = rand
    pcount += 1
    Exit Do
    End If
    Loop
    ElseIf pcount > 8 < 13 Then
    Do
    If pcount = 9 Then
    twist()
    lblP1Card5.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 10 Then
    twist()
    lblP2Card5.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 11 Then
    twist()
    lblP3Card5.Text = rand
    pcount += 1
    Exit Do
    ElseIf pcount = 12 Then
    twist()
    lblP4Card5.Text = rand
    pcount += 1
    Exit Do
    End If
    Loop
    End If
    this worked until th ecounter hit 9 and then it would not enter the third set of if statements. I am aware that this is not a good approach and would appreciatte any help with this issue.

    One thought i had was to increment the label number for player and card but i could not get that to work either.

    please help


    thanks in advance

    tim

  2. #2
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Creating player turns

    Are the players doing the same thing each turn? Or is the second turn for a player supposed to be different? Why are you going to 9?

    If you use the same turn code, then just declare one variable at the top of your Form.

    Code:
    Dim playerTurn as Integer
    And use:
    Code:
    If playerTurn = 1 Then
    'Player1 Turn Code
    playerTurn = 2
    Else
    'Player2 Turn Code
    playerTurn = 1
    End
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width