More refactoring work ....
This commit is contained in:
parent
815fa7d2d1
commit
cccb2eff5b
2 changed files with 8 additions and 12 deletions
|
@ -17,10 +17,8 @@ app.game =
|
|||
|
||||
@hud.render()
|
||||
|
||||
step: ->
|
||||
|
||||
mousedown: (event)->
|
||||
tile = @posToTile(event.x, event.y)
|
||||
tile = posToTile(event.x, event.y)
|
||||
tile.click(event.button)
|
||||
|
||||
@currentSelectedTile.deselect() if @currentSelectedTile
|
||||
|
@ -28,7 +26,7 @@ app.game =
|
|||
@currentSelectedTile = tile
|
||||
|
||||
mousemove: (event)->
|
||||
tile = @posToTile(event.x, event.y)
|
||||
tile = posToTile(event.x, event.y)
|
||||
|
||||
if tile
|
||||
if tile != @currentHoveredTile
|
||||
|
@ -50,12 +48,6 @@ app.game =
|
|||
createMiner: ->
|
||||
if @currentSelectedTile and @checkRessources 'lubinit', 30, true
|
||||
@currentSelectedTile.entity = new Miner
|
||||
@currentSelectedTile.deselect() if @currentSelectedTile
|
||||
@currentSelectedTile = null
|
||||
|
||||
posToTile: (x, y)->
|
||||
pos = (Math.floor(y/8)*20) + Math.floor(x/8)
|
||||
@map[pos]
|
||||
|
||||
checkRessources: (type, amount, drain = false) ->
|
||||
if @resources[type] >= amount
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
getRandomInt = (min, max) ->
|
||||
Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
||||
allResourceTypes = ->
|
||||
(k for own k of app.game.resources)
|
||||
(k for own k of app.game.resources)
|
||||
|
||||
posToTile = (x, y)->
|
||||
pos = (Math.floor(y/8)*20) + Math.floor(x/8)
|
||||
app.game.map[pos]
|
||||
|
|
Loading…
Reference in a new issue