Changes
This commit is contained in:
parent
9f863f232d
commit
ebae442b9b
3 changed files with 19 additions and 16 deletions
|
@ -13,7 +13,7 @@ class Tile extends BaseEntity
|
|||
|
||||
click: (button)->
|
||||
# console.log button
|
||||
@isSelected = true
|
||||
# @isSelected = true
|
||||
|
||||
moveIn: ->
|
||||
@isActive = true
|
||||
|
|
|
@ -6,6 +6,8 @@ app.game =
|
|||
@miners = []
|
||||
@miners.push = new Miner
|
||||
|
||||
@currentHoveredTile = new Tile
|
||||
|
||||
render: ->
|
||||
app.layer.save().scale(5, 5)
|
||||
|
||||
|
@ -20,6 +22,22 @@ app.game =
|
|||
|
||||
step: ->
|
||||
|
||||
mousedown: (event)->
|
||||
@posToTile(event.x, event.y).click(event.button)
|
||||
|
||||
mousemove: (event)->
|
||||
tile = @posToTile(event.x, event.y)
|
||||
|
||||
if tile
|
||||
if tile != @currentHoveredTile
|
||||
tile.moveIn()
|
||||
@currentHoveredTile.moveOut()
|
||||
@currentHoveredTile = tile
|
||||
|
||||
posToTile: (x, y)->
|
||||
pos = (Math.floor(y/8/5)*20) + Math.floor(x/8/5)
|
||||
@map[pos]
|
||||
|
||||
map: []
|
||||
|
||||
resources:
|
||||
|
|
|
@ -6,7 +6,6 @@ app = playground({
|
|||
|
||||
create: ->
|
||||
@loadImages "layers", "active", "selected", "entities"
|
||||
@currentHoveredTile = new Tile
|
||||
|
||||
ready: ->
|
||||
@game.start()
|
||||
|
@ -14,22 +13,8 @@ app = playground({
|
|||
|
||||
step: ->
|
||||
|
||||
mousedown: (event)->
|
||||
@posToTile(event.x, event.y).click(event.button)
|
||||
|
||||
mousemove: (event)->
|
||||
tile = @posToTile(event.x, event.y)
|
||||
if tile != @currentHoveredTile
|
||||
tile.moveIn()
|
||||
@currentHoveredTile.moveOut()
|
||||
@currentHoveredTile = tile
|
||||
|
||||
render: ->
|
||||
@layer.clear "#00f"
|
||||
@game.render()
|
||||
|
||||
posToTile: (x, y)->
|
||||
pos = (Math.floor(y/8/5)*20) + Math.floor(x/8/5)
|
||||
@game.map[pos]
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue