Final Bomberman movement!

This commit is contained in:
Jeremy Penner 2021-04-03 23:13:33 -04:00
parent 02099c9461
commit 238dcee158

View file

@ -16,14 +16,6 @@
(map.world-to-tile)
(rules.tile-at)))
(fn wall-collides? [x y rules]
(-?> (tile-at x y rules)
(. :wall)))
(fn bomb-collides? [x y rules]
(-?> (tile-at x y rules)
(. :bomb)))
(fn bomberman.collides? [[x y] rules]
(let [tile (tile-at x y rules)]
(and tile (or tile.bomb tile.wall))))
@ -63,11 +55,12 @@
(fn bomberman.update [entity dt rules]
(set entity.vel (direct bomberman.keymap (* dim.tilesize 3)))
(local [x y] entity.pos)
(local [dx dy] (vec* entity.vel dt))
(let [[dx1 dy1] (bomberman.axis-movement (horizontal x y) x y dx rules)
[dy2 dx2] (bomberman.axis-movement (vertical x y) y x dy rules)]
(set entity.pos [(+ x dx1 dx2) (+ y dy1 dy2)]))
(let [[x y] entity.pos
[dx dy] (vec* entity.vel dt)
[dx1 dy1] (bomberman.axis-movement (horizontal x y) x y dx rules)
[dy2 dx2] (bomberman.axis-movement (vertical x y) y x dy rules)
[dx dy] (if (not= dx 0) [dx1 dy1] [dx2 dy2])]
(set entity.pos [(+ x dx) (+ y dy)]))
(when (love.keyboard.isDown bomberman.keymap.bomb)
(rules.place-bomb (map.world-to-tile entity.pos))))