From ec6ea33ef5b99fabc8cb5290170f91660397012f Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Sat, 6 Dec 2014 16:35:05 +0100 Subject: [PATCH] Mark the active tile --- public/images/active.png | Bin 0 -> 187 bytes src/entities/tile.coffee | 13 ++++++++----- src/entities/tilelayer.coffee | 3 --- src/main.coffee | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 public/images/active.png diff --git a/public/images/active.png b/public/images/active.png new file mode 100644 index 0000000000000000000000000000000000000000..7fa86abe187fbf1b99e3d1eff7af825ada6bda8b GIT binary patch literal 187 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqoCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#9uFJ8k}}sPQD2~tWQl7;iF1B#Zfaf$gL6@8Vo7R>LV0FMhJw4NZ$Nk>pEyvF zsi%u$h{WaOl!SyI=NTBQcvd_RVg>?XKF=Kz%FN8oddzYMjyNy`xF1xt`80jTguN|i aXER)=W4-U^y7n2+00vK2KbLh*2~7as@iCDA literal 0 HcmV?d00001 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: ->