edtris/game/tiles.fnl
2022-04-24 19:39:15 -04:00

28 lines
801 B
Fennel

(local dim (require :game.dim))
(local util (require :lib.util))
(local {: defmethod} (util.require :lib.multimethod))
(local {: drawtile} (util.require :game.tilemap))
(local tileset (util.hot-table ...))
(fn rect [x y color]
(love.graphics.setColor (table.unpack color))
(love.graphics.rectangle :fill
(- x (/ dim.tilesize 2))
(- y (/ dim.tilesize 2))
dim.tilesize
dim.tilesize))
(defmethod drawtile :wall (fn [tile x y] (rect x y [0.7 0.7 0.7])))
(defmethod drawtile :block (fn [tile x y] (rect x y [0.4 0.4 0.4])))
(set tileset.tetristile
{" " {:name :empty
:empty true}
"X" {:name :wall
:wall true}
"#" {:name :block
:wall true}})
tileset.hot