Miners do cost something, now

This commit is contained in:
Ruben Müller 2014-12-06 20:05:02 +01:00
parent 40dade0aa2
commit 61c9bbbbaf
2 changed files with 20 additions and 5 deletions

View file

@ -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

View file

@ -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