Draw the tiles

This commit is contained in:
Aaron Mueller 2014-12-06 12:37:57 +01:00
parent 374ccd95ce
commit 5bda68d44a
4 changed files with 21 additions and 12 deletions

View file

@ -1,3 +1,3 @@
class Base_entity
class BaseEntity
constructor: (options) ->
{} = options
{} = options

View file

@ -1,4 +1,4 @@
class Tile extends Base_entity
class Tile extends BaseEntity
constructor: (options) ->
super options
@ -10,8 +10,11 @@ class Tile extends Base_entity
new Tilelayer type: 'gold'
]
@currentLayer = 0
tick: (delta) ->
# TODO: digging deeper?
render: ->
app.layer.fillStyle("#fff").fillRect(0, 0, 8, 8);
render: (x, y)->
tile = @layers[@currentLayer]
tile.render(app.layer, x, y)

View file

@ -1,3 +1,10 @@
class Tilelayer extends Base_entity
class Tilelayer extends BaseEntity
constructor: (options) ->
{@type, @depth, @amount} = options
{@type, @depth, @amount} = options
render: (layer, x, y)->
# TODO: Draw sprite
color = "green"
layer.fillStyle color
.fillRect x*8, y*8, 8, 8

View file

@ -1,4 +1,4 @@
app.game = {
app.game =
start: ->
for i in [0..20*15]
@map[i] = new Tile
@ -9,8 +9,8 @@ app.game = {
.fillRect 0, 0, 200, 50
render: ->
for i in @map
i.render()
for tile, i in @map
tile.render(i-(Math.floor(i/20)*20), Math.floor(i/20))
step: ->
@hud
@ -18,6 +18,5 @@ app.game = {
map: []
resources:
ore: 50
ore:50
stone: 100
}