This commit is contained in:
Ruben Müller 2014-12-06 14:54:30 +01:00
commit 39053509ff
3 changed files with 8 additions and 17 deletions

View File

@ -5,10 +5,10 @@ class Tile extends BaseEntity
resTypes = (k for own k of app.game.resources)
@layers = []
for restype in resTypes
@layers.push new Tilelayer(type: restype)
for restype, i in resTypes
@layers.push new Tilelayer(type: restype, depth: i)
#@layers = (new Tilelayer(type: restype) for restype in resTypes)
@currentLayer = getRandomInt 0, resTypes.length-1
@currentLayer = 0 #getRandomInt 0, resTypes.length-1
tick: (delta) ->
# TODO: digging deeper?

View File

@ -1,19 +1,10 @@
class Tilelayer extends BaseEntity
constructor: (options) ->
{@type, @depth, @amount} = options
@randomFactor = getRandomInt 0, 4
@sprite = [@randomFactor*8, @depth*8, @randomFactor*8+8, @depth*8+8]
render: (layer, x, y) ->
switch @type
when "stardust" then color = [0, 0, 8, 8]
when "bedrock" then color = [0, 8, 8, 16]
when "lubinit" then color = [0, 16, 8, 24]
when "oxodum" then color = [0, 24, 8, 32]
when "notch" then color = [0, 32, 8, 40]
layer.drawRegion app.images.layers, @sprite, x*8, y*8
#layer.fillStyle color
# .fillRect x*8, y*8, 8, 8
layer.drawRegion app.images.layers, color, x*8, y*8
getSpriteForType: (i) ->

View File

@ -4,7 +4,7 @@ app.game =
@map[i] = new Tile
render: ->
app.layer.save().scale(5, 5)
app.layer.save().scale(3, 3)
for tile, i in @map
tile.render(i-(Math.floor(i/20)*20), Math.floor(i/20))
app.layer.restore()