HUD update

This commit is contained in:
Ruben Müller 2014-12-07 17:08:31 +01:00
parent 8e3d344255
commit 78c245d3e1

View file

@ -43,52 +43,57 @@ app.game.hud =
app.layer.setPixel(resourcePanelColor, x, y) app.layer.setPixel(resourcePanelColor, x, y)
switch panelusage switch panelusage
when 'tile'
@showResources()
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
if currentSelectedTile.entity.isMoveable() if currentSelectedTile.entity.isMoveable()
app.layer.drawRegion @itemArrow.image, @itemArrow.sprite(), 44, 102 app.layer.drawRegion @itemArrow.image, @itemArrow.sprite(), 44, 102
when 'resources' when 'resources'
# resources @showResources()
i = 0
for type, amount of app.game.resources
if amount > 0
tileLayer = @resources[type]
spritePosition = { showResources: ->
x: i*9+@position.x # resources
y: @position.y i = 0
} for type, amount of app.game.resources
if amount > 0
tileLayer = @resources[type]
app.layer.drawRegion app.images.layers, tileLayer.hudSprite, spritePosition.x, spritePosition.y spritePosition = {
x: i*9+@position.x
y: @position.y
}
amountByTwenty = Math.floor(amount/20) app.layer.drawRegion app.images.layers, tileLayer.hudSprite, spritePosition.x, spritePosition.y
amountLeft = amount - amountByTwenty*20
for e in [0..amountLeft]
color = "#0a0"
color = "#0f0" if e == amountLeft
if e < 6 amountByTwenty = Math.floor(amount/20)
x = spritePosition.x-1+e amountLeft = amount - amountByTwenty*20
y = spritePosition.y-1 for e in [0..amountLeft]
else if e < 10 color = "#0a0"
x = spritePosition.x+4 color = "#0f0" if e == amountLeft
y = spritePosition.y-1+e-5
else if e < 15
x = spritePosition.x+14-e
y = spritePosition.y+4
else
x = spritePosition.x-1
y = spritePosition.y+19-e
app.layer.setPixel(color, x, y) if e < 6
x = spritePosition.x-1+e
y = spritePosition.y-1
else if e < 10
x = spritePosition.x+4
y = spritePosition.y-1+e-5
else if e < 15
x = spritePosition.x+14-e
y = spritePosition.y+4
else
x = spritePosition.x-1
y = spritePosition.y+19-e
for f in [0..amountByTwenty] app.layer.setPixel(color, x, y)
if f > 0
color = "#0000ff"
x = spritePosition.x-2+f for f in [0..amountByTwenty]
y = spritePosition.y+7 if f > 0
color = "#0000ff"
app.layer.setPixel(color, x, y) x = spritePosition.x-2+f
y = spritePosition.y+7
i++ app.layer.setPixel(color, x, y)
i++