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)
|
||||
|
||||
@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
|
||||
|
||||
tick: (delta) ->
|
||||
|
|
|
@ -2,16 +2,18 @@ class Tilelayer extends BaseEntity
|
|||
constructor: (options) ->
|
||||
{@type, @depth, @amount} = options
|
||||
|
||||
render: (layer, x, y)->
|
||||
# TODO: Draw sprite
|
||||
|
||||
render: (layer, x, y) ->
|
||||
switch @type
|
||||
when "grass" then color = "green"
|
||||
when "mud" then color = "brown"
|
||||
when "gravel" then color = "lightgrey"
|
||||
when "stone" then color = "darkgrey"
|
||||
when "gold" then color = "yellow"
|
||||
when "stardust" then color = [0, 0, 8, 8]
|
||||
when "bedrock" then color = [0, 0, 8, 8]
|
||||
when "lubinit" then color = [0, 0, 8, 8]
|
||||
when "oxodum" then color = [0, 0, 8, 8]
|
||||
when "notch" then color = [0, 0, 8, 8]
|
||||
|
||||
layer.fillStyle color
|
||||
.fillRect x*8, y*8, 8, 8
|
||||
#layer.fillStyle color
|
||||
# .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,
|
||||
|
||||
create: ->
|
||||
@loadImages "layers"
|
||||
|
||||
ready: ->
|
||||
@game.start()
|
||||
|
|
Loading…
Reference in a new issue