Logic Question...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abueno
    New Member
    • May 2009
    • 16

    Logic Question...

    Hi everybody,

    I am making a tic-tac-toe game where should be payable by two humans, the game should display all the current player turn....my problem is in the logic, when i set the first player=true; .....the output is right for the first player, but not for the second one, or when i set the value of the second player to true, i got the problem in the first player output ej

    Code:
    function players_turn()
     {
    turn1=false;
    turn2=false;
    
    if((turn1==false)&&(turn2==false))
    {
    alert("First player is your turn");
    turn1=true;
    alert("Second player is your turn");
    turn2=true;
    }
     }// I know my problem is in here.
    Any help would be appreciate.
    Last edited by Dormilich; Apr 15 '10, 06:18 AM. Reason: Please use [code] tags when posting code
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi abueno,
    Can i know the reason why you are setting turn2 = true inside the condition. It should come inside the condition where u check turn1 is true. If you set both the turn1 and turn2 to true at a time surely both the conditions will be executed. So remove the trun2=true from the condition.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • abueno
      New Member
      • May 2009
      • 16

      #3
      Originally posted by RamananKaliraja n
      Hi abueno,
      Can i know the reason why you are setting turn2 = true inside the condition. It should come inside the condition where u check turn1 is true. If you set both the turn1 and turn2 to true at a time surely both the conditions will be executed. So remove the trun2=true from the condition.

      Thanks and Regards
      Ramanan Kalirajan
      Hi RamananKaliraja n,

      Thank's for answer me, I made some modifications to my game...I hope that work thanks. again.

      Comment

      Working...