35 lines
769 B
CoffeeScript
35 lines
769 B
CoffeeScript
class Tile extends BaseEntity
|
|
constructor: (options) ->
|
|
super options
|
|
|
|
resTypes = (k for own k of app.game.resources)
|
|
|
|
@layers = []
|
|
for restype, i in resTypes
|
|
@layers.push new Tilelayer(type: restype, depth: i)
|
|
|
|
@currentLayer = 0
|
|
@isActive = false
|
|
|
|
click: (button)->
|
|
# console.log button
|
|
# @isSelected = true
|
|
|
|
moveIn: ->
|
|
@isActive = true
|
|
|
|
moveOut: ->
|
|
@isActive = false
|
|
|
|
tick: (delta) ->
|
|
# TODO: digging deeper?
|
|
|
|
render: (x, y)->
|
|
tileLayer = @layers[@currentLayer]
|
|
app.layer.drawRegion app.images.layers, tileLayer.sprite, x*8, y*8
|
|
|
|
if @isSelected
|
|
app.layer.drawImage app.images.selected, x*8, y*8
|
|
else if @isActive
|
|
app.layer.drawImage app.images.active, x*8, y*8
|