-
-
Save slior/4c0b049047825136fa5124abf492e86f to your computer and use it in GitHub Desktop.
Mancala (8879f316085b5d4511274c429e6015d6bbe6dbfc) - adding highlights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createHighlights(cellCount) | |
{ | |
... | |
let w = (_boardWidthInCells -2)* CELL_SIZE; | |
let t = TOP_LEFT.y; | |
let l = TOP_LEFT.x + CELL_SIZE; | |
let boardHeightInCells = 3; | |
p1Highlight = new fabric.Line([l,t,l+w,t],{selectable:false,stroke:'red',strokeWidth:3}) | |
p2Highlight = new fabric.Line([l,t+(boardHeightInCells*CELL_SIZE),l+w,t+(boardHeightInCells*CELL_SIZE)],{selectable:false,stroke:'red',strokeWidth:3}) | |
... | |
} | |
function toggleHighlights(canvas,player) | |
{ | |
requires(player == 1 || player == 2,"Invalid player when switching highlights") | |
switch (player) | |
{ | |
case 1 : | |
canvas.add(p1Highlight); | |
canvas.remove(p2Highlight); | |
break; | |
case 2 : | |
canvas.add(p2Highlight); | |
canvas.remove(p1Highlight); | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_initializeBoardDrawing() | |
{ | |
... | |
toggleHighlights(cnvs,this.player.number) | |
} | |
togglePlayer() | |
{ | |
... | |
this.canvas.ifPresent( cnvs => { | |
toggleHighlights(cnvs,this.player.number); | |
}) | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment