You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cardGame/public/js/canvas/draw.js

43 lines
1.1 KiB
JavaScript

function drawGameBoard(){
// Reset board
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawPlayerNames();
}
function drawPlayerNames(){
let playerWeight = 'normal';
if(gameData.playerId == gameData.playerTurn){ playerWeight = 'bold'; }
let opponentWeight = 'normal';
if(gameData.opponentId == gameData.playerTurn){ opponentWeight = 'bold'; }
// Player Name
printText(gameData.playerId,
50,
canvas.height - 70,
'left', 'alphabetic', 'normal', playerWeight, '10', 'Arial', '#000'
);
printText(gameData.players[gameData.playerId][1].playerId,
50,
canvas.height - 50,
'left', 'alphabetic', 'normal', playerWeight, '10', 'Arial', '#000'
);
// Opponent Name
printText(gameData.opponentId,
canvas.width - (ctx.measureText(gameData.opponentId).width + 50),
50,
'left', 'alphabetic', 'normal', opponentWeight, '10', 'Arial', '#000'
);
printText(gameData.players[gameData.opponentId][1].playerId,
canvas.width - (ctx.measureText(gameData.players[gameData.opponentId][1].playerId).width + 50),
70,
'left', 'alphabetic', 'normal', opponentWeight, '10', 'Arial', '#000'
);
}