Work on HUD

This commit is contained in:
Ruben Müller 2014-12-07 13:42:45 +01:00
parent 3f8532a830
commit 1ce34f3472
2 changed files with 52 additions and 41 deletions

View file

@ -22,12 +22,17 @@ app.game =
mousedown: (event)->
if @isMouseInView event.x, event.y
switch event.button
when 'left'
tile = posToTile(event.x, event.y)
tile.click(event.button)
@currentSelectedTile.deselect() if @currentSelectedTile
tile.select()
@currentSelectedTile = tile
when 'right'
@currentSelectedTile.deselect() if @currentSelectedTile
@currentSelectedTile = null
mousemove: (event)->
if @isMouseInView event.x, event.y

View file

@ -12,6 +12,8 @@ app.game.hud =
)
render: ->
panelusage = 'resources'
app.layer.drawImage app.images.hud, 0, 11*8
currentSelectedTile = app.game.currentSelectedTile
@ -19,11 +21,11 @@ app.game.hud =
app.layer.drawRegion app.images.layers, currentSelectedTile.getCurrentLayer().sprite, 15, 100
if currentSelectedTile.entity
panelusage = 'entity'
app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 15, 100
# silo capacity
usedSiloStoragePercent = (100 / app.game.availableSiloStorage()) * app.game.usedSiloStorage()
for f in [0..100]
color = "#333"
color = "#fff" if f < usedSiloStoragePercent
@ -33,6 +35,10 @@ app.game.hud =
app.layer.setPixel(color, x, y)
switch panelusage
when 'entity'
app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 44, 102
when 'resources'
# resources
i = 0
for type, amount of app.game.resources