Commits

Anonymous committed acbe046

Different color size for each level and fix score bug

Comments (0)

Files changed (1)

 var COLORS = ['blue', 'green', 'orange', 'red', 'yellow'];
 var NUM_ROWS = 10;
 var NUM_COLS = 15;
+var NUM_COLORS = COLORS.length;
 var SCORE = 0;
 var BLANK = 'blank.png';
 /* We cache the images in the board since calling 'cell_color' with jQuery
 */
 var BOARD = [];
 
-var SIZES = {
+var LEVELS = {
     easy: {
-        num_rows: 5,
-        num_cols: 5
+        num_rows: 6,
+        num_cols: 6,
+        num_colors: 3,
     },
     medium: {
         num_rows: 9,
-        num_cols: 9
+        num_cols: 9,
+        num_colors: 4
     },
     difficult: {
         num_rows: NUM_ROWS,
-        num_cols: NUM_COLS
+        num_cols: NUM_COLS,
+        num_colors: NUM_COLORS
     }
 };
 
 function random_color() {
-    return COLORS[parseInt(Math.random() * COLORS.length)] + '.png';
+    return COLORS[parseInt(Math.random() * NUM_COLORS)] + '.png';
 }
 
 function cell_color(row, col, color) {
 }
 
 function update_score(count) {
-    SCORE = SCORE + (count * count);
-    set_score(SCORE);
+    var score = parseInt($('#score').html());
+    score = score + (count * count);
+    set_score(score);
 }
 
 function initialize_board() {
 }
 
 function change_level(level) {
-    NUM_ROWS = SIZES[level]['num_rows'];
-    NUM_COLS = SIZES[level]['num_cols'];
+    NUM_ROWS = LEVELS[level]['num_rows'];
+    NUM_COLS = LEVELS[level]['num_cols'];
+    NUM_COLORS = LEVELS[level]['num_colors'];
 
     $('#board').empty();
     initialize_board();