changes ...

This commit is contained in:
Aaron Mueller 2014-12-06 14:52:03 +01:00
parent e25de69561
commit 2dc33d9c36
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()