ld31-space-diggers/src/tools.coffee
2014-12-07 14:13:04 +01:00

16 lines
296 B
CoffeeScript

getRandomInt = (min, max) ->
Math.floor(Math.random() * (max - min + 1)) + min;
allResourceTypes = ->
(k for own k of app.game.resources)
posToTile = (x, y)->
app.game.map[xyToPos(x, y)]
posToXY = (pos)->
y = Math.floor(pos/20)
x = pos-(y*20)
[x, y]
xyToPos = (x, y)->
y*20 + x