From abb1d3c3da733ebe427788bfa7571ea3aa0e3cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20M=C3=BCller?= Date: Sun, 7 Dec 2014 15:13:19 +0100 Subject: [PATCH] Colored capacity panel --- src/hud.coffee | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/hud.coffee b/src/hud.coffee index bfac5c8..b6c1544 100644 --- a/src/hud.coffee +++ b/src/hud.coffee @@ -4,7 +4,7 @@ app.game.hud = @position = x: 45, y: 103 - @itemArrow = new AnimatedItem maxFrames: 12, image: app.images.actions, speed: 50 + @itemArrow = new AnimatedItem maxFrames: 10, image: app.images.actions, speed: 50 @resources = [] for restype, i in resTypes @@ -20,6 +20,8 @@ app.game.hud = currentSelectedTile = app.game.currentSelectedTile if currentSelectedTile != null + panelusage = 'tile' + app.layer.drawRegion app.images.layers, currentSelectedTile.getCurrentLayer().sprite, 15, 100 if currentSelectedTile.entity @@ -27,20 +29,24 @@ app.game.hud = app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 15, 100 # silo capacity - usedSiloStoragePercent = (100 / app.game.availableSiloStorage()) * app.game.usedSiloStorage() + usedSiloStoragePercent = Math.round((100 / app.game.availableSiloStorage()) * app.game.usedSiloStorage()) for f in [0..100] - color = "#333" - color = "#fff" if f < usedSiloStoragePercent + resourcePanelColor = "#333" + + if f <= usedSiloStoragePercent + colorStep = Math.round((usedSiloStoragePercent/100)*5) + resourcePanelColor = ["#0a0", "#0a0", "#aa0", "#f60", "#a00", "#f00"][colorStep] x = 44+f y = 112 - app.layer.setPixel(color, x, y) + app.layer.setPixel(resourcePanelColor, x, y) switch panelusage when 'entity' #app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 44, 102 - app.layer.drawRegion @itemArrow.image, @itemArrow.sprite(), 44, 102 + if currentSelectedTile.entity.isMoveable() + app.layer.drawRegion @itemArrow.image, @itemArrow.sprite(), 44, 102 when 'resources' # resources i = 0