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)
@currentLayer = 0 #getRandomInt 0, resTypes.length-1
click: (button)->
console.log button
moveIn: ->
console.log "in"
moveOut: ->
console.log "out"
tick: (delta) ->
# TODO: digging deeper?

View file

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

View file

@ -1,20 +1,35 @@
app = playground({
width: 8*20*5,
height: 8*15*5,
width: 8*20,
height: 8*15,
scaleToFit: true,
smoothing: false,
create: ->
@loadImages "layers"
@currentHoveredTile = new Tile
ready: ->
@game.start()
@setState @game
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: ->
@layer.clear("#00f");
@game.render
@layer.clear "#00f"
@game.render()
posToTile: (x, y)->
pos = (Math.floor(y/8)*20) + Math.floor(x/8)
@game.map[pos]
})