// using canvas to draw the line
var ctx = map.getCanvasContext();
ctx.beginPath();
ctx.strokeStyle = color; //make lasers colored
ctx.lineWidth = 5;
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
//color switcher by telephone
player.setColor('red');
player.setPhoneCallback(function(){
var color = player.getColor();
switch(color)
{
case 'red':
player.setColor('yellow');
break;
case 'yellow':
player.setColor('teal');
break;
case 'teal':
player.setColor('red');
break;
}
});
ctx.strokeStyle = color;
//---
var j = 0;
var colors = ['red', 'yellow', 'teal'];
player.setPhoneCallback( function(){
player.setColor( colors[ (j++)%3 ] );
} );
Nothing in the first area.
The following code in the second area:
getRandomInt = function(){return 600;};
// using canvas to draw the line
var ctx = map.getCanvasContext();
ctx.beginPath();
ctx.strokeStyle = 'white';
ctx.lineWidth = 5;
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
// take advantages of the closure create by `map.createLine`
// so all lasers will be of the same color of the player
color = player.getColor();