Conflicts:
	src/main.coffee
This commit is contained in:
Ruben Müller 2014-12-06 16:33:44 +01:00
commit b8be2ab4f8
3 changed files with 31 additions and 9 deletions

View file

@ -9,6 +9,15 @@ class Tile extends BaseEntity
@layers.push new Tilelayer(type: restype, depth: i) @layers.push new Tilelayer(type: restype, depth: i)
@currentLayer = 0 #getRandomInt 0, resTypes.length-1 @currentLayer = 0 #getRandomInt 0, resTypes.length-1
click: (button)->
console.log button
moveIn: ->
console.log "in"
moveOut: ->
console.log "out"
tick: (delta) -> tick: (delta) ->
# TODO: digging deeper? # TODO: digging deeper?

View file

@ -4,12 +4,10 @@ app.game =
@map[i] = new Tile @map[i] = new Tile
render: -> render: ->
app.layer.save().scale(5, 5)
for tile, i in @map for tile, i in @map
y = Math.floor(i/20) y = Math.floor(i/20)
x = i-(y*20) x = i-(y*20)
tile.render(x, y) tile.render(x, y)
app.layer.restore()
@hud.render() @hud.render()
step: -> step: ->

View file

@ -1,20 +1,35 @@
app = playground({ app = playground({
width: 8*20*5, width: 8*20,
height: 8*15*5, height: 8*15,
scaleToFit: true, scaleToFit: true,
smoothing: false, smoothing: false,
create: -> create: ->
@loadImages "layers" @loadImages "layers"
@currentHoveredTile = new Tile
ready: -> ready: ->
@game.start() @game.start()
@setState @game @setState @game
step: -> step: ->
mousedown: (event)->
@posToTile(event.x, event.y).click(event.button)
mousemove: (event)->
tile = @posToTile(event.x, event.y)
if tile != @currentHoveredTile
tile.moveIn()
@currentHoveredTile.moveOut()
@currentHoveredTile = tile
render: -> render: ->
@layer.clear("#00f"); @layer.clear "#00f"
@game.render @game.render()
posToTile: (x, y)->
pos = (Math.floor(y/8)*20) + Math.floor(x/8)
@game.map[pos]
}) })