From b510790ef811483bd448cbbcda5d2e7c3e89336e Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Sun, 7 Dec 2014 16:27:44 +0100 Subject: [PATCH] can't click on dead tiles --- src/game.coffee | 9 ++++++--- src/tiles/tile.coffee | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/game.coffee b/src/game.coffee index e140d12..23d7343 100644 --- a/src/game.coffee +++ b/src/game.coffee @@ -5,8 +5,7 @@ app.game = @map[20*5+10].entity = new Base @mouseX = 0 - @mouseY = 0 - + @mouseY = 0 @currentHoveredTile = new Tile(-1) @currentSelectedTile = null @@ -23,10 +22,14 @@ app.game = @speechbubble.render() mousedown: (event)-> + tile = posToTile(Math.floor(event.x/8), Math.floor(event.y/8)) + + # Can't click on dead tiles + return unless tile and tile.isBuildable + if @isMouseInView event.x/8, event.y/8 switch event.button when 'left' - tile = posToTile(Math.floor(event.x/8), Math.floor(event.y/8)) tile.click(event.button) @currentSelectedTile.deselect() if @currentSelectedTile diff --git a/src/tiles/tile.coffee b/src/tiles/tile.coffee index ccb40ba..814f286 100644 --- a/src/tiles/tile.coffee +++ b/src/tiles/tile.coffee @@ -16,6 +16,9 @@ class Tile @randomSeed = Math.round(Math.random()*10) click: (button)-> + # Some tiles are not buildable + return unless @isBuildable + if button == "left" if (app.game.availableSiloStorage() - app.game.usedSiloStorage()) > 0 if @layers[@currentLayer].collect()