Added big game of life.
authorEugen Sawin <sawine@me73.com>
Thu, 05 Jan 2012 23:04:57 +0100
changeset 81a76b2fb0f21f
parent 80 ba69edadfc4c
child 82 cb8897d7f508
Added big game of life.
experiments.html
factory/v2012/experiments.html
factory/v2012/gameoflife.html
factory/v2012/script.js
gameoflife.html
script.js
     1.1 --- a/experiments.html	Thu Jan 05 17:03:06 2012 +0100
     1.2 +++ b/experiments.html	Thu Jan 05 23:04:57 2012 +0100
     1.3 @@ -37,7 +37,7 @@
     1.4            <p>
     1.5  <!--<img src="images/world.png" alt="world map" height="280" width="100%" />
     1.6  -->
     1.7 -<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);" onload="draw(0, 0, 0, 0, 0);">
     1.8 +<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);">
     1.9  </canvas> 
    1.10  <button onclick="draw(0, -2, 0, 0, 0);">Left</button>
    1.11  <button onclick="draw(0, 2, 0, 0, 0);">Right</button>
     2.1 --- a/factory/v2012/experiments.html	Thu Jan 05 17:03:06 2012 +0100
     2.2 +++ b/factory/v2012/experiments.html	Thu Jan 05 23:04:57 2012 +0100
     2.3 @@ -1,7 +1,7 @@
     2.4  <p>
     2.5  <!--<img src="images/world.png" alt="world map" height="280" width="100%" />
     2.6  -->
     2.7 -<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);" onload="draw(0, 0, 0, 0, 0);">
     2.8 +<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);">
     2.9  </canvas> 
    2.10  <button onclick="draw(0, -2, 0, 0, 0);">Left</button>
    2.11  <button onclick="draw(0, 2, 0, 0, 0);">Right</button>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/factory/v2012/gameoflife.html	Thu Jan 05 23:04:57 2012 +0100
     3.3 @@ -0,0 +1,5 @@
     3.4 +<p>
     3.5 +  <canvas id="gameoflife" width="670" height="670">
     3.6 +    FIND A BETTER BROWSER.
     3.7 +  </canvas>
     3.8 +</p>
     4.1 --- a/factory/v2012/script.js	Thu Jan 05 17:03:06 2012 +0100
     4.2 +++ b/factory/v2012/script.js	Thu Jan 05 23:04:57 2012 +0100
     4.3 @@ -4,7 +4,7 @@
     4.4  var gameoflife;
     4.5  
     4.6  $(document).ready(function() {   
     4.7 -    simulation = new Simulation(document.getElementById("sim"), 670, 50);  
     4.8 +    simulation = new Simulation(document.getElementById("sim"), 670, 50, 4);  
     4.9      var image = new Image();
    4.10      image.onload = init_logo;
    4.11      image.src = "images/logobase.png";
    4.12 @@ -32,7 +32,14 @@
    4.13          }
    4.14      }    
    4.15      window.onEachFrame = onEachFrame;   
    4.16 -    window.onEachFrame(update);    
    4.17 +    window.onEachFrame(update);  
    4.18 +    var pos = document.location.href.lastIndexOf("/") + 1; 
    4.19 +    var page = document.location.href.substr(pos);
    4.20 +    if (page == "experiments.html") {
    4.21 +        draw(0, 0, 0, 0, 0);
    4.22 +    } else if (page == "gameoflife.html") {
    4.23 +        init_gameoflife();
    4.24 +    }
    4.25  });
    4.26  
    4.27  $(document).keypress(function(event) {
    4.28 @@ -277,13 +284,12 @@
    4.29  }
    4.30  
    4.31  function init_gameoflife() {
    4.32 -    var canvas = document.getElementById("gameoflife"); alert("h");
    4.33 -    if (cavans) {
    4.34 -        gameoflife = new Simulation(canvas, 670, 670);
    4.35 +    var canvas = document.getElementById("gameoflife");
    4.36 +    if (canvas) {
    4.37 +        gameoflife = new Simulation(canvas, 670, 670, 8);
    4.38          $("#gameoflife").mousemove(function(event) { 
    4.39              gameoflife.mouse_moved(mouse_pos(event, "#gameoflife")); 
    4.40 -        });
    4.41 -        alert("h");
    4.42 +        });       
    4.43      }
    4.44  }
    4.45  
    4.46 @@ -617,7 +623,7 @@
    4.47      return d;
    4.48  }
    4.49  
    4.50 -function Simulation(canvas, w, h) {
    4.51 +function Simulation(canvas, w, h, cell_size) {
    4.52      this.last_update = 0;
    4.53      this.last_draw = 0;
    4.54      this.last_mouse_moved = 0;
    4.55 @@ -628,7 +634,7 @@
    4.56      this.context = canvas.getContext("2d");    
    4.57      this.pos_queue = new Array();
    4.58      this.cell_queue = new Array();  
    4.59 -    var cell_size = 3;
    4.60 +    this.cell_size = cell_size;
    4.61      this.grid = new Grid(this.canvas.width, this.canvas.height, cell_size);
    4.62      draw_sim_lines();
    4.63  }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/gameoflife.html	Thu Jan 05 23:04:57 2012 +0100
     5.3 @@ -0,0 +1,74 @@
     5.4 +<!DOCTYPE html>
     5.5 +<html lang="en">
     5.6 +  <head>
     5.7 +    <title>ME73</title>
     5.8 +    <meta name="author" content="Eugen Sawin <sawine@me73.com>" />
     5.9 +    <meta name="description" content="A Digital Playground" />
    5.10 +    <meta name="robots" content="index, follow, noarchive" />
    5.11 +    <meta name="googlebot" content="noarchive" />
    5.12 +    <script src="jquery.js"></script>
    5.13 +    <script src="script.js"></script>
    5.14 +    <link rel="stylesheet" href="dark.css" type="text/css" />
    5.15 +    <script type="application/javascript">
    5.16 +      var _gaq = _gaq || [];
    5.17 +      _gaq.push(['_setAccount', 'UA-2137333-1']);
    5.18 +      _gaq.push(['_trackPageview']);
    5.19 +      (function() {
    5.20 +      var ga = document.createElement('script'); ga.type = 'text/javascript';
    5.21 +      ga.async = true;
    5.22 +      ga.src = ('https:' == document.location.protocol ? 'https://ssl' :'http://www') 
    5.23 +      + '.google-analytics.com/ga.js';
    5.24 +      var s = document.getElementsByTagName('script')[0];
    5.25 +      s.parentNode.insertBefore(ga, s);
    5.26 +      })();
    5.27 +    </script>
    5.28 +  </head>
    5.29 +  <body>
    5.30 +    <div id="wrap">
    5.31 +      <div id="header">
    5.32 +        <canvas id="logo">
    5.33 +          FIND A BETTER BROWSER
    5.34 +        </canvas>
    5.35 +        <canvas id="sim">
    5.36 +        </canvas>
    5.37 +      </div>
    5.38 +      <div id="content-wrap">
    5.39 +        <div id="main">
    5.40 +          <p>
    5.41 +  <canvas id="gameoflife" width="670" height="670">
    5.42 +    FIND A BETTER BROWSER.
    5.43 +  </canvas>
    5.44 +</p>
    5.45 +
    5.46 +        </div>
    5.47 +        <div id="sidebar">
    5.48 +          <p>           
    5.49 +	    <a href="resume.html" class="float-left"></a>            
    5.50 +            I'm a programmer,<br />
    5.51 +            a student of computer science,<br />
    5.52 +            a music enthusiast.<br />
    5.53 +            This is my site.
    5.54 +          </p>
    5.55 +          <div id="random_quote"></div>
    5.56 +        </div>
    5.57 +      </div>
    5.58 +      <div id="footer">
    5.59 +        <div id="footer-left">
    5.60 +          <p>
    5.61 +            <a href="mailto:sawine@me73.com">
    5.62 +	      Eugen Sawin<br/>Software Enginnering &amp; Research</a>
    5.63 +          </p>
    5.64 +        </div>
    5.65 +        <div id="footer-right">
    5.66 +          <p class="align-right">
    5.67 +            <a href="index.html">Home</a> | <a href="#top">Top</a>
    5.68 +          </p>
    5.69 +        </div>
    5.70 +      </div>
    5.71 +    </div>
    5.72 +    <script type="application/javascript">
    5.73 +      javascript:load_random_quote();
    5.74 +    </script>
    5.75 +  </body>
    5.76 +</html>
    5.77 +
     6.1 --- a/script.js	Thu Jan 05 17:03:06 2012 +0100
     6.2 +++ b/script.js	Thu Jan 05 23:04:57 2012 +0100
     6.3 @@ -4,7 +4,7 @@
     6.4  var gameoflife;
     6.5  
     6.6  $(document).ready(function() {   
     6.7 -    simulation = new Simulation(document.getElementById("sim"), 670, 50);  
     6.8 +    simulation = new Simulation(document.getElementById("sim"), 670, 50, 4);  
     6.9      var image = new Image();
    6.10      image.onload = init_logo;
    6.11      image.src = "images/logobase.png";
    6.12 @@ -32,7 +32,14 @@
    6.13          }
    6.14      }    
    6.15      window.onEachFrame = onEachFrame;   
    6.16 -    window.onEachFrame(update);    
    6.17 +    window.onEachFrame(update);  
    6.18 +    var pos = document.location.href.lastIndexOf("/") + 1; 
    6.19 +    var page = document.location.href.substr(pos);
    6.20 +    if (page == "experiments.html") {
    6.21 +        draw(0, 0, 0, 0, 0);
    6.22 +    } else if (page == "gameoflife.html") {
    6.23 +        init_gameoflife();
    6.24 +    }
    6.25  });
    6.26  
    6.27  $(document).keypress(function(event) {
    6.28 @@ -277,13 +284,12 @@
    6.29  }
    6.30  
    6.31  function init_gameoflife() {
    6.32 -    var canvas = document.getElementById("gameoflife"); alert("h");
    6.33 -    if (cavans) {
    6.34 -        gameoflife = new Simulation(canvas, 670, 670);
    6.35 +    var canvas = document.getElementById("gameoflife");
    6.36 +    if (canvas) {
    6.37 +        gameoflife = new Simulation(canvas, 670, 670, 8);
    6.38          $("#gameoflife").mousemove(function(event) { 
    6.39              gameoflife.mouse_moved(mouse_pos(event, "#gameoflife")); 
    6.40 -        });
    6.41 -        alert("h");
    6.42 +        });       
    6.43      }
    6.44  }
    6.45  
    6.46 @@ -617,7 +623,7 @@
    6.47      return d;
    6.48  }
    6.49  
    6.50 -function Simulation(canvas, w, h) {
    6.51 +function Simulation(canvas, w, h, cell_size) {
    6.52      this.last_update = 0;
    6.53      this.last_draw = 0;
    6.54      this.last_mouse_moved = 0;
    6.55 @@ -628,7 +634,7 @@
    6.56      this.context = canvas.getContext("2d");    
    6.57      this.pos_queue = new Array();
    6.58      this.cell_queue = new Array();  
    6.59 -    var cell_size = 3;
    6.60 +    this.cell_size = cell_size;
    6.61      this.grid = new Grid(this.canvas.width, this.canvas.height, cell_size);
    6.62      draw_sim_lines();
    6.63  }