function drawGameBoard(){ // Reset board ctx.clearRect(0, 0, canvas.width, canvas.height); drawPlayerNames(); } function drawPlayerNames(){ // Player Name ctx.fillText(gameData.playerId, 50, canvas.height - 70); ctx.fillText(gameData.players[gameData.playerId][1].playerId, 50, canvas.height - 50); // Opponent Name ctx.fillText(gameData.opponentId, canvas.width - (ctx.measureText(gameData.opponentId).width + 50), 50); ctx.fillText(gameData.players[gameData.opponentId][1].playerId, canvas.width - (ctx.measureText(gameData.players[gameData.opponentId][1].playerId).width + 50), 70); }