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
Post a Comment