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) -> keyup: (event) ->
switch event.key switch event.key
when "m" then @createMiner() when "m" then @createMiner()
when "c" then @cheatah()
when "space" when "space"
@currentSelectedTile.deselect() if @currentSelectedTile @currentSelectedTile.deselect() if @currentSelectedTile
@currentSelectedTile = null @currentSelectedTile = null
createMiner: -> createMiner: ->
if @currentSelectedTile if @currentSelectedTile and @checkRessources 'lubinit', 30, true
newMiner = new Miner newMiner = new Miner
@miners.push = newMiner @miners.push = newMiner
@currentSelectedTile.attachMiner newMiner @currentSelectedTile.attachMiner newMiner
@currentSelectedTile.deselect() if @currentSelectedTile
@currentSelectedTile = null
posToTile: (x, y)-> posToTile: (x, y)->
pos = (Math.floor(y/8)*20) + Math.floor(x/8) pos = (Math.floor(y/8)*20) + Math.floor(x/8)
@map[pos] @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: [] map: []
maxTileAmount: 15 maxTileAmount: 15

View file

@ -1,11 +1,11 @@
app.game.hud = app.game.hud =
render: -> render: ->
app.layer.drawImage app.images.hud, 0, 12*8+2 app.layer.drawImage app.images.hud, 0, 12*8+2
posy = 49 posy = 15
for type, amount of app.game.resources for type, amount of app.game.resources
if amount > 0 if amount > 0
app.layer app.layer
.fillStyle "#000" .fillStyle "#000"
.font "22px Minecraftia" .font "10px Arial"
.wrappedText(amount+" x "+type, 11, posy, 800) .wrappedText(amount+" x "+type, 5, posy, 800)
posy += 29 posy += 10