Draw the tiles
This commit is contained in:
parent
374ccd95ce
commit
5bda68d44a
4 changed files with 21 additions and 12 deletions
|
@ -1,3 +1,3 @@
|
|||
class Base_entity
|
||||
class BaseEntity
|
||||
constructor: (options) ->
|
||||
{} = options
|
|
@ -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)
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
class Tilelayer extends Base_entity
|
||||
class Tilelayer extends BaseEntity
|
||||
constructor: (options) ->
|
||||
{@type, @depth, @amount} = options
|
||||
|
||||
render: (layer, x, y)->
|
||||
# TODO: Draw sprite
|
||||
color = "green"
|
||||
layer.fillStyle color
|
||||
.fillRect x*8, y*8, 8, 8
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -20,4 +20,3 @@ app.game = {
|
|||
resources:
|
||||
ore:50
|
||||
stone: 100
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue