Fixed minor bug.
1.1 --- a/dark.css Thu Jan 05 23:04:57 2012 +0100
1.2 +++ b/dark.css Thu Jan 05 23:29:27 2012 +0100
1.3 @@ -208,9 +208,13 @@
1.4 left: 25px;
1.5 height: 100px;
1.6 width: 670px;
1.7 +}
1.8 +
1.9 +#gameoflife {
1.10 + background: black;
1.11 }
1.12
1.13 -#sim {
1.14 +#sim {
1.15 border-style: none;
1.16 position: relative;
1.17 margin: 0;
2.1 --- a/factory/v2012/dark.css Thu Jan 05 23:04:57 2012 +0100
2.2 +++ b/factory/v2012/dark.css Thu Jan 05 23:29:27 2012 +0100
2.3 @@ -208,9 +208,13 @@
2.4 left: 25px;
2.5 height: 100px;
2.6 width: 670px;
2.7 +}
2.8 +
2.9 +#gameoflife {
2.10 + background: black;
2.11 }
2.12
2.13 -#sim {
2.14 +#sim {
2.15 border-style: none;
2.16 position: relative;
2.17 margin: 0;
3.1 --- a/factory/v2012/script.js Thu Jan 05 23:04:57 2012 +0100
3.2 +++ b/factory/v2012/script.js Thu Jan 05 23:29:27 2012 +0100
3.3 @@ -4,7 +4,8 @@
3.4 var gameoflife;
3.5
3.6 $(document).ready(function() {
3.7 - simulation = new Simulation(document.getElementById("sim"), 670, 50, 4);
3.8 + simulation = new Simulation(document.getElementById("sim"),
3.9 + 670, 50, 4, green, background);
3.10 var image = new Image();
3.11 image.onload = init_logo;
3.12 image.src = "images/logobase.png";
3.13 @@ -248,7 +249,13 @@
3.14 context.closePath();
3.15 context.strokeStyle = colour1a.str();
3.16 context.stroke();
3.17 -
3.18 + var colour1e = new Colour(0, 0, 0, 0.05);
3.19 + context.beginPath();
3.20 + context.moveTo(70, h - 1);
3.21 + context.lineTo(w - 71, h - 1);
3.22 + context.closePath();
3.23 + context.strokeStyle = colour1e.str();
3.24 + context.stroke();
3.25 var colour1b = new Colour(0, 0, 0, 0.05);
3.26 context.beginPath();
3.27 context.moveTo(50, h - 1);
3.28 @@ -256,7 +263,13 @@
3.29 context.closePath();
3.30 context.strokeStyle = colour1b.str();
3.31 context.stroke();
3.32 -
3.33 + var colour1c = new Colour(0, 0, 0, 0.05);
3.34 + context.beginPath();
3.35 + context.moveTo(25, h - 1);
3.36 + context.lineTo(w - 26, h - 1);
3.37 + context.closePath();
3.38 + context.strokeStyle = colour1c.str();
3.39 + context.stroke();
3.40 var colour1d = new Colour(0, 0, 0, 0.05);
3.41 context.beginPath();
3.42 context.moveTo(10, h - 1);
3.43 @@ -286,7 +299,8 @@
3.44 function init_gameoflife() {
3.45 var canvas = document.getElementById("gameoflife");
3.46 if (canvas) {
3.47 - gameoflife = new Simulation(canvas, 670, 670, 8);
3.48 + gameoflife = new Simulation(canvas, 670, 670, 8,
3.49 + green, black);
3.50 $("#gameoflife").mousemove(function(event) {
3.51 gameoflife.mouse_moved(mouse_pos(event, "#gameoflife"));
3.52 });
3.53 @@ -549,8 +563,8 @@
3.54 }
3.55
3.56 function Grid(width, height, cell_size) {
3.57 - this.width = parseInt(width / cell_size);
3.58 - this.height = parseInt(height / cell_size);
3.59 + this.width = parseInt(width / cell_size + 0.5);
3.60 + this.height = parseInt(height / cell_size + 0.5);
3.61 this.canvas_width = width;
3.62 this.canvas_height = height;
3.63 this.cell_size = cell_size;
3.64 @@ -601,7 +615,7 @@
3.65 if (this.y + 1 < this.grid.height) {
3.66 this._neighbours.push(this.grid.cell(this.x-1, this.y+1));
3.67 }
3.68 - }
3.69 + }
3.70 if (this.x + 1 < this.grid.width) {
3.71 this._neighbours.push(this.grid.cell(this.x+1, this.y));
3.72 if (this.y + 1 < this.grid.height) {
3.73 @@ -623,7 +637,7 @@
3.74 return d;
3.75 }
3.76
3.77 -function Simulation(canvas, w, h, cell_size) {
3.78 +function Simulation(canvas, w, h, cell_size, life_colour, dead_colour) {
3.79 this.last_update = 0;
3.80 this.last_draw = 0;
3.81 this.last_mouse_moved = 0;
3.82 @@ -635,6 +649,8 @@
3.83 this.pos_queue = new Array();
3.84 this.cell_queue = new Array();
3.85 this.cell_size = cell_size;
3.86 + this.life_colour = life_colour;
3.87 + this.dead_colour = dead_colour;
3.88 this.grid = new Grid(this.canvas.width, this.canvas.height, cell_size);
3.89 draw_sim_lines();
3.90 }
3.91 @@ -642,7 +658,8 @@
3.92 var now = $.now();
3.93 if (this.redraw.length) {
3.94 var cell = this.redraw.pop();
3.95 - this.context.fillStyle = cell.value == 1 ? green.str() : background.str();
3.96 + this.context.fillStyle = cell.value == 1 ?
3.97 + this.life_colour.str() : this.dead_colour.str();
3.98 this.context.fillRect(cell.canvas_x, cell.canvas_y,
3.99 this.grid.cell_size, this.grid.cell_size);
3.100 this.last_draw = $.now();
4.1 --- a/script.js Thu Jan 05 23:04:57 2012 +0100
4.2 +++ b/script.js Thu Jan 05 23:29:27 2012 +0100
4.3 @@ -4,7 +4,8 @@
4.4 var gameoflife;
4.5
4.6 $(document).ready(function() {
4.7 - simulation = new Simulation(document.getElementById("sim"), 670, 50, 4);
4.8 + simulation = new Simulation(document.getElementById("sim"),
4.9 + 670, 50, 4, green, background);
4.10 var image = new Image();
4.11 image.onload = init_logo;
4.12 image.src = "images/logobase.png";
4.13 @@ -248,7 +249,13 @@
4.14 context.closePath();
4.15 context.strokeStyle = colour1a.str();
4.16 context.stroke();
4.17 -
4.18 + var colour1e = new Colour(0, 0, 0, 0.05);
4.19 + context.beginPath();
4.20 + context.moveTo(70, h - 1);
4.21 + context.lineTo(w - 71, h - 1);
4.22 + context.closePath();
4.23 + context.strokeStyle = colour1e.str();
4.24 + context.stroke();
4.25 var colour1b = new Colour(0, 0, 0, 0.05);
4.26 context.beginPath();
4.27 context.moveTo(50, h - 1);
4.28 @@ -256,7 +263,13 @@
4.29 context.closePath();
4.30 context.strokeStyle = colour1b.str();
4.31 context.stroke();
4.32 -
4.33 + var colour1c = new Colour(0, 0, 0, 0.05);
4.34 + context.beginPath();
4.35 + context.moveTo(25, h - 1);
4.36 + context.lineTo(w - 26, h - 1);
4.37 + context.closePath();
4.38 + context.strokeStyle = colour1c.str();
4.39 + context.stroke();
4.40 var colour1d = new Colour(0, 0, 0, 0.05);
4.41 context.beginPath();
4.42 context.moveTo(10, h - 1);
4.43 @@ -286,7 +299,8 @@
4.44 function init_gameoflife() {
4.45 var canvas = document.getElementById("gameoflife");
4.46 if (canvas) {
4.47 - gameoflife = new Simulation(canvas, 670, 670, 8);
4.48 + gameoflife = new Simulation(canvas, 670, 670, 8,
4.49 + green, black);
4.50 $("#gameoflife").mousemove(function(event) {
4.51 gameoflife.mouse_moved(mouse_pos(event, "#gameoflife"));
4.52 });
4.53 @@ -549,8 +563,8 @@
4.54 }
4.55
4.56 function Grid(width, height, cell_size) {
4.57 - this.width = parseInt(width / cell_size);
4.58 - this.height = parseInt(height / cell_size);
4.59 + this.width = parseInt(width / cell_size + 0.5);
4.60 + this.height = parseInt(height / cell_size + 0.5);
4.61 this.canvas_width = width;
4.62 this.canvas_height = height;
4.63 this.cell_size = cell_size;
4.64 @@ -601,6 +615,8 @@
4.65 if (this.y + 1 < this.grid.height) {
4.66 this._neighbours.push(this.grid.cell(this.x-1, this.y+1));
4.67 }
4.68 + } else {
4.69 + this._neighbours.push(this.grid.cell(this.grid.width-1, this.y));
4.70 }
4.71 if (this.x + 1 < this.grid.width) {
4.72 this._neighbours.push(this.grid.cell(this.x+1, this.y));
4.73 @@ -611,6 +627,8 @@
4.74 if (this.y > 0) {
4.75 this._neighbours.push(this.grid.cell(this.x+1, this.y-1));
4.76 }
4.77 + } else {
4.78 + this._neighbours.push(this.grid.cell(0, this.y));
4.79 }
4.80 return this._neighbours;
4.81 }
4.82 @@ -623,7 +641,7 @@
4.83 return d;
4.84 }
4.85
4.86 -function Simulation(canvas, w, h, cell_size) {
4.87 +function Simulation(canvas, w, h, cell_size, life_colour, dead_colour) {
4.88 this.last_update = 0;
4.89 this.last_draw = 0;
4.90 this.last_mouse_moved = 0;
4.91 @@ -635,6 +653,8 @@
4.92 this.pos_queue = new Array();
4.93 this.cell_queue = new Array();
4.94 this.cell_size = cell_size;
4.95 + this.life_colour = life_colour;
4.96 + this.dead_colour = dead_colour;
4.97 this.grid = new Grid(this.canvas.width, this.canvas.height, cell_size);
4.98 draw_sim_lines();
4.99 }
4.100 @@ -642,7 +662,8 @@
4.101 var now = $.now();
4.102 if (this.redraw.length) {
4.103 var cell = this.redraw.pop();
4.104 - this.context.fillStyle = cell.value == 1 ? green.str() : background.str();
4.105 + this.context.fillStyle = cell.value == 1 ?
4.106 + this.life_colour.str() : this.dead_colour.str();
4.107 this.context.fillRect(cell.canvas_x, cell.canvas_y,
4.108 this.grid.cell_size, this.grid.cell_size);
4.109 this.last_draw = $.now();