Jump to content

Switching players

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Alex_j

Alex_j

    Newbie

  • Members
  • PipPip
  • 29 posts
Hi, I need to switch between the two players of my game, so when they click on the go button the value of a dice is sent into the the label, but it needs to take turns. I have tried using while and if statements to do this but nothing is working, instead when the button is clicked it sends the values at the same time. I want it to do Player 1 first then Player 2. Help!

#2
terroare

terroare

    Newbie

  • Members
  • PipPip
  • 16 posts
I think a solution cloud be a bool instance variable, in you main class.
When the payer1's turn set it to true, when player2's turn set it to false, and do the checking each time you click the button.
Or if you have a player class, create a static instace variable, witch is shared by all the objects created from that class.
I hope I cloud help you :)