Skip to content

Commit

Permalink
A bit more stable, but still buggy
Browse files Browse the repository at this point in the history
  • Loading branch information
ksgy committed Mar 29, 2015
1 parent 4d4f1d8 commit 5ecdc92
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/javascript/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ class BlockGrid {
}

blockClicked (e, block) {
console.log('v14');
console.log('v16');

this.neighbours = [block];
this.getNeighBour(block);
this.applyGravity();
if(this.getNeighBour(block) != false) {
this.applyGravity();
}


}

getNeighBour (block) {

if(block.x < 0 || block.x >= MAX_X || block.y < 0 || block.y >= MAX_Y || block.colour == 'grey') return;

if(block.x < 0 || block.x >= MAX_X || block.y < 0 || block.y >= MAX_Y || block.colour == 'grey') {
return false;
};

let topBlock;
try { topBlock = this.grid[block.x][block.y+1] } catch(e){ console.log('e', e); };
Expand Down

0 comments on commit 5ecdc92

Please sign in to comment.