Chapter 3, Exercise 2 – Experimental Board Layouts
Now that you can make createLayout build a different grid pattern, write code to generate an entirely new layout. For example, you could draw only every alternate column or build a more creative layout.
One simple change is to add spaces between bubbles by changing createLayout in board.js:
var createLayout = function(){
var rows = [];
for(var i=0;i<NUM_ROWS;i++){
var row = [];
var startCol = i%2 == 0 ? 1 : 0;
for(var j=startCol;j<NUM_COLS;j+=3){
var bubble = BubbleShoot.Bubble.create(i,j);
row[j] = bubble;
};
rows.push(row);
};
return rows;
};
Again, this doesn’t look like it’s going to make the game particularly easy.
Leave a Reply