Add game tick

This commit is contained in:
Aaron Mueller 2014-12-06 20:52:56 +01:00
parent 2a865bb72e
commit c7b600a15a
2 changed files with 15 additions and 5 deletions

View file

@ -45,6 +45,10 @@ class Tile extends BaseEntity
detachMiner: -> detachMiner: ->
@currentMiner = null @currentMiner = null
gameTick: ->
if @currentMiner
@layers[@currentLayer].collect()
render: (x, y)-> render: (x, y)->
tileLayer = @layers[@currentLayer] tileLayer = @layers[@currentLayer]
app.layer.drawRegion app.images.layers, tileLayer.sprite, x*8, y*8 app.layer.drawRegion app.images.layers, tileLayer.sprite, x*8, y*8

View file

@ -6,6 +6,9 @@ app.game =
@currentHoveredTile = new Tile @currentHoveredTile = new Tile
@currentSelectedTile = new Tile @currentSelectedTile = new Tile
# Start the game tick
window.setInterval(@gameTick, 1000)
render: -> render: ->
for tile, i in @map for tile, i in @map
y = Math.floor(i/20) y = Math.floor(i/20)
@ -41,6 +44,9 @@ app.game =
@currentSelectedTile.deselect() if @currentSelectedTile @currentSelectedTile.deselect() if @currentSelectedTile
@currentSelectedTile = null @currentSelectedTile = null
gameTick: ->
tile.gameTick() for tile in @map
createMiner: -> createMiner: ->
if @currentSelectedTile and @checkRessources 'lubinit', 30, true if @currentSelectedTile and @checkRessources 'lubinit', 30, true
newMiner = new Miner newMiner = new Miner