bomberpac/game/entity.fnl

20 lines
566 B
Plaintext
Raw Normal View History

2021-02-07 21:56:19 +00:00
(local util (require :lib.util))
2021-04-11 03:39:42 +00:00
(local {: defmulti : defmethod} (util.require :lib.multimethod))
(local {: vec* : vec+ : dir-from-key} (util.require :game.helpers))
(local dim (require :game.dim))
2021-02-07 21:56:19 +00:00
(local entity {})
(fn entity.move [pos vel dt]
(vec+ pos (vec* vel dt)))
(fn entity.direct [keymap speed]
(vec* (dir-from-key keymap) speed))
2021-04-11 03:39:42 +00:00
(set entity.draw (defmulti #(or $1.draw $1.entity) :draw ...))
(set entity.update (defmulti #(or $1.update $1.entity) :update ...))
(defmethod entity.draw :default #nil)
(defmethod entity.update :default #nil)
entity
2021-02-07 21:56:19 +00:00