diff --git a/src/game.coffee b/src/game.coffee index 69b71d5..57d323b 100644 --- a/src/game.coffee +++ b/src/game.coffee @@ -38,20 +38,35 @@ app.game = keyup: (event) -> switch event.key when "m" then @createMiner() + when "c" then @cheatah() when "space" @currentSelectedTile.deselect() if @currentSelectedTile @currentSelectedTile = null createMiner: -> - if @currentSelectedTile + if @currentSelectedTile and @checkRessources 'lubinit', 30, true newMiner = new Miner + @miners.push = newMiner @currentSelectedTile.attachMiner newMiner + @currentSelectedTile.deselect() if @currentSelectedTile + @currentSelectedTile = null + posToTile: (x, y)-> pos = (Math.floor(y/8)*20) + Math.floor(x/8) @map[pos] + checkRessources: (type, amount, drain = false) -> + if @resources[type] >= amount + @resources[type] -= amount if drain + return true + false + + cheatah: -> + for type, amount of @resources + @resources[type] = 100 + map: [] maxTileAmount: 15 diff --git a/src/hud.coffee b/src/hud.coffee index be7f855..5c086bb 100644 --- a/src/hud.coffee +++ b/src/hud.coffee @@ -1,11 +1,11 @@ app.game.hud = render: -> app.layer.drawImage app.images.hud, 0, 12*8+2 - posy = 49 + posy = 15 for type, amount of app.game.resources if amount > 0 app.layer .fillStyle "#000" - .font "22px Minecraftia" - .wrappedText(amount+" x "+type, 11, posy, 800) - posy += 29 + .font "10px Arial" + .wrappedText(amount+" x "+type, 5, posy, 800) + posy += 10