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