ld31-space-diggers/src/tools.coffee

17 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