Skip to content

Instantly share code, notes, and snippets.

@slior

slior/drawing.js Secret

Created November 1, 2020 12:44
Show Gist options
  • Save slior/5c1ae2d98e081b88900d66b59a58f759 to your computer and use it in GitHub Desktop.
Save slior/5c1ae2d98e081b88900d66b59a58f759 to your computer and use it in GitHub Desktop.
Mancala (e8a35c608f320f8e18e30ee36cc5dbc43b721d1e) - drawing cell
function drawCell(boardCell,stoneCount)
{
var left = 0;
var top = 0;
switch (true)
{
case board.isPlayer1Cell(boardCell) :
top = CELL_SIZE /2 - FONT_SIZE/2;
left = boardCell * CELL_SIZE + CELL_SIZE/2 - FONT_SIZE/2;
break;
case board.isPlayer2Cell(boardCell) :
top = CELL_SIZE * 2.5 - FONT_SIZE/2;
left = (board.totalCellCount() - boardCell) * CELL_SIZE + CELL_SIZE/2 - FONT_SIZE/2;
break;
default : ERR("Invalid board cell: must be either player 1 or player 2 cell");
}
drawText(stoneCount,TOP_LEFT.x + left,TOP_LEFT.y + top);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment