CHAPTER 7
Code Explanation
var everything = []; To hold everything
var curwall; For wall in progress
var wallwidth = 5; Fixed wall width
var wallstyle = "rgb(200,0,200)"; Fixed wall color
var walls = []; Hold all walls
var inmotion = false; Flag while wall being built by dragging
var unit = 10; Unit of movement for token
function Token(sx,sy,rad,stylestring,n) { Function header to build token
this.sx = sx; Set sx property
this.sy = sy; ... sy
this.rad = rad; ... rad (radius)
this.draw = drawtoken; Set the draw method
this.n = n; ... n number of sides
this.angle = (2*Math.PI)/n Compute and set angle
this.moveit = movetoken; Set moveit method
this.fillstyle = stylestring; Set color
} Close function
function drawtoken() { Function header drawtoken
ctx.fillStyle=this.fillstyle; Set color
var i; Index
var rad = this.rad; Set rad