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))
|
2021-03-07 16:55:50 +00:00
|
|
|
(local {: vec* : vec+ : dir-from-key} (util.require :game.helpers))
|
|
|
|
(local dim (require :game.dim))
|
2021-02-07 21:56:19 +00:00
|
|
|
|
2021-03-07 16:55:50 +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)
|
|
|
|
|
2021-03-07 16:55:50 +00:00
|
|
|
entity
|
2021-02-07 21:56:19 +00:00
|
|
|
|