Add pass turn and turn identifier
Pass turn via server Identify whose turn by making their name boldfeature/clientSideSimplify
parent
993f68636b
commit
aaf687acb8
@ -0,0 +1,22 @@
|
|||||||
|
function printText(text, positionX, positionY, alignment = 'left', baseline = 'alphabetic', style = 'normal', weight = 'normal', size = '10', font = 'Arial', colour = '#000'){
|
||||||
|
|
||||||
|
// Save the styling, and content already on the canvas
|
||||||
|
ctx.save();
|
||||||
|
|
||||||
|
// Do the alterations and print the text
|
||||||
|
context.textAlign = alignment;
|
||||||
|
context.textBaseline = baseline;
|
||||||
|
|
||||||
|
// Set the font styling
|
||||||
|
ctx.font = style+' '+weight+' '+size+'pt'+' '+font;
|
||||||
|
//ctx.font-style = fontStyle; // normal, italic, oblique
|
||||||
|
ctx.fillStyle = colour;
|
||||||
|
|
||||||
|
// Actually add the text
|
||||||
|
ctx.fillText(text, positionX, positionY);
|
||||||
|
|
||||||
|
// Restore the prior existing canvas content
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
// Any socket request/responses for the actual game (when in a match)
|
||||||
|
|
||||||
|
function requestPassTurn(){
|
||||||
|
console.log('>> passTurn');
|
||||||
|
socket.emit('passTurn', gameData.roomId, gameData.playerId);
|
||||||
|
}
|
||||||
|
socket.on('responsePassTurn', function (data) {
|
||||||
|
console.log('<< passTurn');
|
||||||
|
// Set turn data for clients (bolds their name)
|
||||||
|
updateTurn(data.turn, data.playerTurn);
|
||||||
|
drawGameBoard();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Functions like this would be elsewhere, do client-side
|
||||||
|
// validation THEN request stuff from the server?
|
||||||
|
// This is here for now, as it's used by the button
|
||||||
|
function passTurn(){
|
||||||
|
requestPassTurn();
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue