changes ...
This commit is contained in:
parent
e25de69561
commit
2dc33d9c36
3 changed files with 8 additions and 17 deletions
|
@ -5,10 +5,10 @@ class Tile extends BaseEntity
|
||||||
resTypes = (k for own k of app.game.resources)
|
resTypes = (k for own k of app.game.resources)
|
||||||
|
|
||||||
@layers = []
|
@layers = []
|
||||||
for restype in resTypes
|
for restype, i in resTypes
|
||||||
@layers.push new Tilelayer(type: restype)
|
@layers.push new Tilelayer(type: restype, depth: i)
|
||||||
#@layers = (new Tilelayer(type: restype) for restype in resTypes)
|
#@layers = (new Tilelayer(type: restype) for restype in resTypes)
|
||||||
@currentLayer = getRandomInt 0, resTypes.length-1
|
@currentLayer = 0 #getRandomInt 0, resTypes.length-1
|
||||||
|
|
||||||
tick: (delta) ->
|
tick: (delta) ->
|
||||||
# TODO: digging deeper?
|
# TODO: digging deeper?
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
class Tilelayer extends BaseEntity
|
class Tilelayer extends BaseEntity
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
{@type, @depth, @amount} = options
|
{@type, @depth, @amount} = options
|
||||||
|
@randomFactor = getRandomInt 0, 4
|
||||||
|
@sprite = [@randomFactor*8, @depth*8, @randomFactor*8+8, @depth*8+8]
|
||||||
|
|
||||||
render: (layer, x, y) ->
|
render: (layer, x, y) ->
|
||||||
switch @type
|
layer.drawRegion app.images.layers, @sprite, x*8, y*8
|
||||||
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.fillStyle color
|
|
||||||
# .fillRect x*8, y*8, 8, 8
|
|
||||||
|
|
||||||
layer.drawRegion app.images.layers, color, x*8, y*8
|
|
||||||
|
|
||||||
getSpriteForType: (i) ->
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ app.game =
|
||||||
@map[i] = new Tile
|
@map[i] = new Tile
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
app.layer.save().scale(5, 5)
|
app.layer.save().scale(3, 3)
|
||||||
for tile, i in @map
|
for tile, i in @map
|
||||||
tile.render(i-(Math.floor(i/20)*20), Math.floor(i/20))
|
tile.render(i-(Math.floor(i/20)*20), Math.floor(i/20))
|
||||||
app.layer.restore()
|
app.layer.restore()
|
||||||
|
|
Loading…
Reference in a new issue