Mark the active tile
This commit is contained in:
parent
b8be2ab4f8
commit
ec6ea33ef5
4 changed files with 9 additions and 9 deletions
BIN
public/images/active.png
Normal file
BIN
public/images/active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 187 B |
|
@ -8,20 +8,23 @@ class Tile extends BaseEntity
|
||||||
for restype, i in resTypes
|
for restype, i in resTypes
|
||||||
@layers.push new Tilelayer(type: restype, depth: i)
|
@layers.push new Tilelayer(type: restype, depth: i)
|
||||||
|
|
||||||
@currentLayer = 0 #getRandomInt 0, resTypes.length-1
|
@currentLayer = 0
|
||||||
|
@isActive = false
|
||||||
|
|
||||||
click: (button)->
|
click: (button)->
|
||||||
console.log button
|
console.log button
|
||||||
|
|
||||||
moveIn: ->
|
moveIn: ->
|
||||||
console.log "in"
|
@isActive = true
|
||||||
|
|
||||||
moveOut: ->
|
moveOut: ->
|
||||||
console.log "out"
|
@isActive = false
|
||||||
|
|
||||||
tick: (delta) ->
|
tick: (delta) ->
|
||||||
# TODO: digging deeper?
|
# TODO: digging deeper?
|
||||||
|
|
||||||
render: (x, y)->
|
render: (x, y)->
|
||||||
tile = @layers[@currentLayer]
|
tileLayer = @layers[@currentLayer]
|
||||||
tile.render(app.layer, x, y)
|
app.layer.drawRegion app.images.layers, tileLayer.sprite, x*8, y*8
|
||||||
|
if @isActive
|
||||||
|
app.layer.drawImage app.images.active, x*8, y*8
|
||||||
|
|
|
@ -3,6 +3,3 @@ class Tilelayer extends BaseEntity
|
||||||
{@type, @depth, @amount} = options
|
{@type, @depth, @amount} = options
|
||||||
@randomFactor = getRandomInt 0, 4
|
@randomFactor = getRandomInt 0, 4
|
||||||
@sprite = [@randomFactor*8, @depth*8, 8, 8]
|
@sprite = [@randomFactor*8, @depth*8, 8, 8]
|
||||||
|
|
||||||
render: (layer, x, y) ->
|
|
||||||
layer.drawRegion app.images.layers, @sprite, x*8, y*8
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ app = playground({
|
||||||
smoothing: false,
|
smoothing: false,
|
||||||
|
|
||||||
create: ->
|
create: ->
|
||||||
@loadImages "layers"
|
@loadImages "layers", "active"
|
||||||
@currentHoveredTile = new Tile
|
@currentHoveredTile = new Tile
|
||||||
|
|
||||||
ready: ->
|
ready: ->
|
||||||
|
|
Loading…
Reference in a new issue