Change player in javascript game -


game: onclick startbutton > mathrandom first player starts game. 4 pictures: 2 of > player1 , player2. 2> player turn.

need help: on button click > next player turn

function game(){     var playerturn;     playerturn=parseint(math.random()*2);        if(playerturn==0){playerturn=1;window.document.player1.src="cache/player3.png";}      else{playerturn=0;window.document.player2.src="cache/player4.png";}      } 

any appreciated.

function game(){     var playerturn;     if (math.random()>0.5){         playerturn=1;        window.document.player1.src="cache/player3.png";     } else {         playerturn=0;         window.document.player2.src="cache/player4.png";     } } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -