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) ->
|
constructor: (options) ->
|
||||||
super options
|
super options
|
||||||
|
|
||||||
|
@seed = getRandomInt 0, 4
|
||||||
|
|
||||||
@layers = [
|
@layers = [
|
||||||
new Tilelayer type: 'grass'
|
new Tilelayer type: 'grass'
|
||||||
new Tilelayer type: 'mud'
|
new Tilelayer type: 'mud'
|
||||||
|
@ -10,7 +12,7 @@ class Tile extends BaseEntity
|
||||||
new Tilelayer type: 'gold'
|
new Tilelayer type: 'gold'
|
||||||
]
|
]
|
||||||
|
|
||||||
@currentLayer = 0
|
@currentLayer = getRandomInt 0, 4
|
||||||
|
|
||||||
tick: (delta) ->
|
tick: (delta) ->
|
||||||
# TODO: digging deeper?
|
# TODO: digging deeper?
|
||||||
|
|
|
@ -4,7 +4,14 @@ class Tilelayer extends BaseEntity
|
||||||
|
|
||||||
render: (layer, x, y)->
|
render: (layer, x, y)->
|
||||||
# TODO: Draw sprite
|
# 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
|
layer.fillStyle color
|
||||||
.fillRect x*8, y*8, 8, 8
|
.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