2021-03-07 16:55:50 +00:00
|
|
|
(local util (require :lib.util))
|
|
|
|
(local dim (require :game.dim))
|
|
|
|
(local {: direct : move} (util.require :game.entity))
|
|
|
|
(local map (require :game.tilemap))
|
|
|
|
|
|
|
|
(local bomberman {})
|
|
|
|
(set bomberman.keymap {:up :w :down :s :left :a :right :d :bomb :x})
|
|
|
|
|
|
|
|
(fn bomberman.draw [entity]
|
|
|
|
(love.graphics.setColor 0.2 0.2 0.2)
|
|
|
|
(love.graphics.circle :fill (. entity.pos 1) (. entity.pos 2) (/ dim.tilesize 2)))
|
|
|
|
(fn bomberman.update [entity dt rules]
|
|
|
|
(set entity.vel (direct bomberman.keymap (* dim.tilesize 3)))
|
|
|
|
(set entity.pos (move entity.pos entity.vel dt))
|
|
|
|
(when (love.keyboard.isDown bomberman.keymap.bomb)
|
|
|
|
(rules.place-bomb (map.world-to-tile entity.pos))))
|
|
|
|
|
|
|
|
(fn bomberman.new [pos]
|
|
|
|
{: pos :vel [0 0] :draw (util.fn bomberman :draw) :update (util.fn bomberman :update)})
|
|
|
|
|
|
|
|
bomberman
|