Working on tile stuff.

This commit is contained in:
Ruben Müller 2014-12-06 12:57:25 +01:00
parent 5bda68d44a
commit c52e532d69
3 changed files with 14 additions and 3 deletions

View File

@ -1,7 +1,9 @@
class Tile extends BaseEntity
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?

View File

@ -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
View File

@ -0,0 +1,2 @@
getRandomInt = (min, max) ->
Math.floor(Math.random() * (max - min + 1)) + min;