ld31-space-diggers/src/tools.coffee

17 lines
296 B
CoffeeScript
Raw Permalink Normal View History

2014-12-06 12:57:25 +01:00
getRandomInt = (min, max) ->
2014-12-06 23:17:58 +01:00
Math.floor(Math.random() * (max - min + 1)) + min;
2014-12-06 22:07:28 +01:00
allResourceTypes = ->
2014-12-06 23:17:58 +01:00
(k for own k of app.game.resources)
posToTile = (x, y)->
2014-12-07 14:07:13 +01:00
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