Tileset fun
This commit is contained in:
parent
76414f3ea2
commit
a44117d1dd
3 changed files with 18 additions and 12 deletions
|
@ -4,7 +4,10 @@ class Tile extends BaseEntity
|
||||||
|
|
||||||
resTypes = (k for own k of app.game.resources)
|
resTypes = (k for own k of app.game.resources)
|
||||||
|
|
||||||
@layers = (new Tilelayer(type: restype) for restype in resTypes)
|
@layers = []
|
||||||
|
for restype in resTypes
|
||||||
|
@layers.push new Tilelayer(type: restype)
|
||||||
|
#@layers = (new Tilelayer(type: restype) for restype in resTypes)
|
||||||
@currentLayer = getRandomInt 0, resTypes.length-1
|
@currentLayer = getRandomInt 0, resTypes.length-1
|
||||||
|
|
||||||
tick: (delta) ->
|
tick: (delta) ->
|
||||||
|
|
|
@ -3,15 +3,17 @@ class Tilelayer extends BaseEntity
|
||||||
{@type, @depth, @amount} = options
|
{@type, @depth, @amount} = options
|
||||||
|
|
||||||
render: (layer, x, y) ->
|
render: (layer, x, y) ->
|
||||||
# TODO: Draw sprite
|
|
||||||
|
|
||||||
switch @type
|
switch @type
|
||||||
when "grass" then color = "green"
|
when "stardust" then color = [0, 0, 8, 8]
|
||||||
when "mud" then color = "brown"
|
when "bedrock" then color = [0, 0, 8, 8]
|
||||||
when "gravel" then color = "lightgrey"
|
when "lubinit" then color = [0, 0, 8, 8]
|
||||||
when "stone" then color = "darkgrey"
|
when "oxodum" then color = [0, 0, 8, 8]
|
||||||
when "gold" then color = "yellow"
|
when "notch" then color = [0, 0, 8, 8]
|
||||||
|
|
||||||
layer.fillStyle color
|
#layer.fillStyle color
|
||||||
.fillRect x*8, y*8, 8, 8
|
# .fillRect x*8, y*8, 8, 8
|
||||||
|
|
||||||
|
layer.drawRegion app.images.layers, color, x*8, y*8
|
||||||
|
|
||||||
|
getSpriteForType: (i) ->
|
||||||
|
|
|
@ -5,6 +5,7 @@ app = playground({
|
||||||
smoothing: false,
|
smoothing: false,
|
||||||
|
|
||||||
create: ->
|
create: ->
|
||||||
|
@loadImages "layers"
|
||||||
|
|
||||||
ready: ->
|
ready: ->
|
||||||
@game.start()
|
@game.start()
|
||||||
|
|
Loading…
Reference in a new issue