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
|
@ -10,6 +10,15 @@ class Tile extends BaseEntity
|
|||
|
||||
@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?
|
||||
|
||||
|
|
|
@ -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: ->
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
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()
|
||||
|
@ -13,8 +14,22 @@ app = playground({
|
|||
|
||||
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]
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue