HUD stuff
This commit is contained in:
parent
fe496a24d4
commit
d266258052
4 changed files with 26 additions and 8 deletions
Binary file not shown.
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 2.8 KiB |
|
@ -5,7 +5,7 @@ app.game =
|
||||||
@map[20*5+10].entity = new Base
|
@map[20*5+10].entity = new Base
|
||||||
|
|
||||||
@currentHoveredTile = new Tile
|
@currentHoveredTile = new Tile
|
||||||
@currentSelectedTile = new Tile
|
@currentSelectedTile = null
|
||||||
|
|
||||||
# Start the game tick
|
# Start the game tick
|
||||||
window.setInterval @tick, 1000
|
window.setInterval @tick, 1000
|
||||||
|
@ -72,9 +72,9 @@ app.game =
|
||||||
maxTileAmount: 15
|
maxTileAmount: 15
|
||||||
|
|
||||||
availableSiloStorage: ->
|
availableSiloStorage: ->
|
||||||
space = 0
|
space = 50
|
||||||
for tile in app.game.map
|
for tile in app.game.map
|
||||||
space += tile.spaceProvided
|
space += tile.spaceProvided if tile.spaceProvided
|
||||||
space
|
space
|
||||||
|
|
||||||
usedSiloStorage: ->
|
usedSiloStorage: ->
|
||||||
|
|
|
@ -14,10 +14,25 @@ app.game.hud =
|
||||||
render: ->
|
render: ->
|
||||||
app.layer.drawImage app.images.hud, 0, 11*8
|
app.layer.drawImage app.images.hud, 0, 11*8
|
||||||
|
|
||||||
|
if app.game.currentSelectedTile != null
|
||||||
|
app.layer.drawRegion app.images.layers, app.game.currentSelectedTile.getCurrentLayer().sprite, 15, 100
|
||||||
|
|
||||||
|
# silo capacity
|
||||||
|
usedSiloStoragePercent = (100 / app.game.availableSiloStorage()) * app.game.usedSiloStorage()
|
||||||
|
|
||||||
|
for f in [0..100]
|
||||||
|
color = "#333"
|
||||||
|
color = "#fff" if f < usedSiloStoragePercent
|
||||||
|
|
||||||
|
x = 44+f
|
||||||
|
y = 112
|
||||||
|
|
||||||
|
app.layer.setPixel(color, x, y)
|
||||||
|
|
||||||
|
# resources
|
||||||
i = 0
|
i = 0
|
||||||
for type, amount of app.game.resources
|
for type, amount of app.game.resources
|
||||||
if amount > 0
|
if amount > 0
|
||||||
#console.log @resources[type]
|
|
||||||
tileLayer = @resources[type]
|
tileLayer = @resources[type]
|
||||||
|
|
||||||
spritePosition = {
|
spritePosition = {
|
||||||
|
|
|
@ -37,8 +37,11 @@ class Tile
|
||||||
deselect: ->
|
deselect: ->
|
||||||
@isSelected = false
|
@isSelected = false
|
||||||
|
|
||||||
|
getCurrentLayer: ->
|
||||||
|
@layers[@currentLayer]
|
||||||
|
|
||||||
render: (x, y)->
|
render: (x, y)->
|
||||||
tileLayer = @layers[@currentLayer]
|
tileLayer = @getCurrentLayer()
|
||||||
app.layer.drawRegion app.images.layers, tileLayer.sprite, x*8, y*8
|
app.layer.drawRegion app.images.layers, tileLayer.sprite, x*8, y*8
|
||||||
|
|
||||||
if @entity
|
if @entity
|
||||||
|
@ -53,10 +56,10 @@ class Tile
|
||||||
color = ["#f00", "#f00", "#f80", "#ff0", "#0f0", "#0f0"][numPercent] if i == numPercent
|
color = ["#f00", "#f00", "#f80", "#ff0", "#0f0", "#0f0"][numPercent] if i == numPercent
|
||||||
app.layer.setPixel(color, x*8+1+i, y*8+6)
|
app.layer.setPixel(color, x*8+1+i, y*8+6)
|
||||||
|
|
||||||
if @isSelected
|
|
||||||
app.layer.drawImage app.images.selected, x*8, y*8
|
|
||||||
|
|
||||||
if @isActive
|
if @isActive
|
||||||
app.layer.drawImage app.images.active, x*8, y*8
|
app.layer.drawImage app.images.active, x*8, y*8
|
||||||
|
|
||||||
|
if @isSelected
|
||||||
|
app.layer.drawImage app.images.selected, x*8, y*8
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue