20 lines
589 B
Fennel
20 lines
589 B
Fennel
(local tiledraw (require :editor.tiledraw))
|
|
|
|
{:map-bitxy (fn [self x y]
|
|
(when (and (>= x 0) (< x 16) (>= y 0) (< y 16))
|
|
(local ibyte (if (< x 8) y (+ y 16)))
|
|
(local ibit
|
|
(if (= x 0) 7
|
|
(< x 8) (- x 1)
|
|
(- x 8)))
|
|
(values ibyte ibit 1)))
|
|
:pixel-color (fn [self b _ ibit]
|
|
(if (= ibit 7) (tiledraw.pal-from-bit (= b 1))
|
|
(= b 1) [255 255 255]
|
|
[0 0 0]))
|
|
:draw-off (fn [self] (set self.bit nil))
|
|
:draw-on (fn [self b] (when (= self.bit nil) (set self.bit (if (= b 1) 0 1))))
|
|
:draw-bits (fn [self] self.bit)
|
|
}
|
|
|