Working on tile stuff.
This commit is contained in:
parent
5bda68d44a
commit
c52e532d69
3 changed files with 14 additions and 3 deletions
|
@ -2,6 +2,8 @@ class Tile extends BaseEntity
|
|||
constructor: (options) ->
|
||||
super options
|
||||
|
||||
@seed = getRandomInt 0, 4
|
||||
|
||||
@layers = [
|
||||
new Tilelayer type: 'grass'
|
||||
new Tilelayer type: 'mud'
|
||||
|
@ -10,7 +12,7 @@ class Tile extends BaseEntity
|
|||
new Tilelayer type: 'gold'
|
||||
]
|
||||
|
||||
@currentLayer = 0
|
||||
@currentLayer = getRandomInt 0, 4
|
||||
|
||||
tick: (delta) ->
|
||||
# TODO: digging deeper?
|
||||
|
|
|
@ -4,7 +4,14 @@ class Tilelayer extends BaseEntity
|
|||
|
||||
render: (layer, x, y)->
|
||||
# TODO: Draw sprite
|
||||
color = "green"
|
||||
|
||||
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"
|
||||
|
||||
layer.fillStyle color
|
||||
.fillRect x*8, y*8, 8, 8
|
||||
|
||||
|
|
2
src/tools.coffee
Normal file
2
src/tools.coffee
Normal file
|
@ -0,0 +1,2 @@
|
|||
getRandomInt = (min, max) ->
|
||||
Math.floor(Math.random() * (max - min + 1)) + min;
|
Loading…
Reference in a new issue