Merge branch 'master' of https://github.com/arg-games/ld31
Conflicts: src/main.coffee
This commit is contained in:
commit
b8be2ab4f8
3 changed files with 31 additions and 9 deletions
|
@ -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?
|
||||||
|
|
|
@ -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: ->
|
||||||
|
|
|
@ -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]
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue