Commits

Sven Hendriks committed df17ec7 Draft

Removed cruft.

  • Participants
  • Parent commits 832ca35

Comments (0)

Files changed (1)

File jquery.conway.js

 */
 /**
  * jQuery conway plugin
- * Copyright (c) 2011, Sven Hendriks (hendriks.sven@googlemail.com)
+ * Copyright (c) 2012, Sven Hendriks (mail@sven-hendriks.de)
  * Licensed under the GPL Version 2 license.
  *
  * This piece of code implements Conway's Game of Life as
     var grid = [];
     var conf = {};
     var stopped = false;
+    // FIXME no hardcoding please
     var colors = ['#006000', '#600000', '#000060'];
     var layers = 3;
 
         }            
     };
 
-    print = function() {
+    display = function() {
         var i = 0, j = 0;
         for(i = 0; i < conf.rows; i += 1) {
             for(j = 0; j < conf.cols; j += 1) {
-                var color = '#101010';
+                var color = '#000000';
                 for(bit = 0, op = 1; bit < layers; bit +=1, op <<= 1) {
                     if((grid[i][j] & op) !== 0) {
                         color = $.xcolor.combine(color, colors[bit]);
                     } else {
                         x = l;
                     }
-
+    
                     // loop over bits
                     for(bit = 0, op = 1; bit < how_many_bits; bit += 1, op <<= 1) {
                         if((grid[y][x] & op) !== 0) {
-                        sums[bit] += 1;
+                            sums[bit] += 1;
                         }
                     }
                 }
             randomfill();
         }
 
-        print();
+        display();
+
+        //delete old_grid;
 
         if( ! stopped) {
             setTimeout(step, 200);
         init : function(params) { 
             $.extend(conf, params);
             return $(this).each(function() {
-                // resize element
-                $(this).css({
-                    position: 'absolute',
-                    width: $(document).width(), 
-                    height: $(document).height(), 
-                    'z-index': -1000,
-                    top: 0,
-                    left: 0 
-                });
-
                 // empty element
                 $(this).empty();
 
                 // create table with rows x cols cells as well as internal datastructures
                 grid = [];
 
+                // TODO get rid of table
                 var table = '<table width="100%" height="100%">';
                 var i = 0;
 
 
                 randomfill();
 
+                // FIXME don't hardcode it that way
                 // init glider
                 grid[0][1] |= 2;
                 grid[1][2] |= 2;
                 grid[6][0] |= 4;
                 grid[6][3] |= 4;
 
-                print();
+                display();
             });
         },
         stop: function() {