Mark the active tile

This commit is contained in:
Aaron Mueller 2014-12-06 16:35:05 +01:00
parent b8be2ab4f8
commit ec6ea33ef5
4 changed files with 9 additions and 9 deletions

BIN
public/images/active.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

View file

@ -8,20 +8,23 @@ class Tile extends BaseEntity
for restype, i in resTypes
@layers.push new Tilelayer(type: restype, depth: i)
@currentLayer = 0 #getRandomInt 0, resTypes.length-1
@currentLayer = 0
@isActive = false
click: (button)->
console.log button
moveIn: ->
console.log "in"
@isActive = true
moveOut: ->
console.log "out"
@isActive = false
tick: (delta) ->
# TODO: digging deeper?
render: (x, y)->
tile = @layers[@currentLayer]
tile.render(app.layer, x, y)
tileLayer = @layers[@currentLayer]
app.layer.drawRegion app.images.layers, tileLayer.sprite, x*8, y*8
if @isActive
app.layer.drawImage app.images.active, x*8, y*8

View file

@ -3,6 +3,3 @@ class Tilelayer extends BaseEntity
{@type, @depth, @amount} = options
@randomFactor = getRandomInt 0, 4
@sprite = [@randomFactor*8, @depth*8, 8, 8]
render: (layer, x, y) ->
layer.drawRegion app.images.layers, @sprite, x*8, y*8

View file

@ -5,7 +5,7 @@ app = playground({
smoothing: false,
create: ->
@loadImages "layers"
@loadImages "layers", "active"
@currentHoveredTile = new Tile
ready: ->