Colored capacity panel
This commit is contained in:
parent
dcf7d78ff9
commit
abb1d3c3da
1 changed files with 12 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue