function Game(stage,xocolor,doc,datastore,activity,sizepalette){ this.margin = 0; this.radius = 0; this.circleswidth = 0; this.circlesheight = 0; this.colours = [xocolor.stroke,xocolor.fill]; this.level = 4; this.turns = 1; this.gridwidth = 7; this.gridheight = 7; this.numFlips = 14; this.startgridwidth = 4; this.startgridheight = 4; this.dots = []; this.stack = []; this.solveTimeout; this.newGameTimeout; //Helper functions this.radiusFromX = function(){ this.margin = 1/50*stage.canvas.width; var diameter = (stage.canvas.width-(this.margin*(this.gridwidth+1)))/this.gridwidth; var radius = diameter/2; return radius; } this.radiusFromY = function(){ this.margin = 1/50*stage.canvas.height; var diameter = (stage.canvas.height-(this.margin*(this.gridheight+1)))/this.gridheight; var radius = diameter/2; return radius; } this.canDoFromX = function(){ var rad = this.radiusFromX(); this.margin = 1/50*stage.canvas.width; if ((((rad*2)*this.gridheight)+(this.margin*(this.gridheight+1)))<=stage.canvas.height){ return rad; } else { return false; } } this.checkGameOver = function(){ var fgWin = true; var bgWin = true; for (var x = 0; x