Colored capacity panel

This commit is contained in:
Ruben Müller 2014-12-07 15:13:19 +01:00
parent dcf7d78ff9
commit abb1d3c3da

View file

@ -4,7 +4,7 @@ app.game.hud =
@position = x: 45, y: 103 @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 = [] @resources = []
for restype, i in resTypes for restype, i in resTypes
@ -20,6 +20,8 @@ app.game.hud =
currentSelectedTile = app.game.currentSelectedTile currentSelectedTile = app.game.currentSelectedTile
if currentSelectedTile != null if currentSelectedTile != null
panelusage = 'tile'
app.layer.drawRegion app.images.layers, currentSelectedTile.getCurrentLayer().sprite, 15, 100 app.layer.drawRegion app.images.layers, currentSelectedTile.getCurrentLayer().sprite, 15, 100
if currentSelectedTile.entity if currentSelectedTile.entity
@ -27,20 +29,24 @@ app.game.hud =
app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 15, 100 app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 15, 100
# silo capacity # 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] for f in [0..100]
color = "#333" resourcePanelColor = "#333"
color = "#fff" if f < usedSiloStoragePercent
if f <= usedSiloStoragePercent
colorStep = Math.round((usedSiloStoragePercent/100)*5)
resourcePanelColor = ["#0a0", "#0a0", "#aa0", "#f60", "#a00", "#f00"][colorStep]
x = 44+f x = 44+f
y = 112 y = 112
app.layer.setPixel(color, x, y) app.layer.setPixel(resourcePanelColor, x, y)
switch panelusage switch panelusage
when 'entity' when 'entity'
#app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 44, 102 #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' when 'resources'
# resources # resources
i = 0 i = 0