diff --git a/public/images/active.png b/public/images/active.png new file mode 100644 index 0000000..7fa86ab Binary files /dev/null and b/public/images/active.png differ diff --git a/src/entities/tile.coffee b/src/entities/tile.coffee index 7f64ad9..9cd4438 100644 --- a/src/entities/tile.coffee +++ b/src/entities/tile.coffee @@ -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 diff --git a/src/entities/tilelayer.coffee b/src/entities/tilelayer.coffee index a63d7b4..5d951d2 100644 --- a/src/entities/tilelayer.coffee +++ b/src/entities/tilelayer.coffee @@ -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 diff --git a/src/main.coffee b/src/main.coffee index 4a76506..569a43f 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -5,7 +5,7 @@ app = playground({ smoothing: false, create: -> - @loadImages "layers" + @loadImages "layers", "active" @currentHoveredTile = new Tile ready: ->