diff --git a/game/main.fnl b/game/main.fnl index f8e4c4d..2876e73 100644 --- a/game/main.fnl +++ b/game/main.fnl @@ -13,6 +13,7 @@ (var pool nil) +(love.graphics.setDefaultFilter :nearest :nearest) (local screen (let [scale 2 canvas-w 800 canvas-h 450] { :screen-w (* canvas-w scale) @@ -77,7 +78,6 @@ (fn love.load [] (love.window.setMode screen.screen-w screen.screen-h) - ; (tset screen :canvas (love.graphics.newCanvas screen.canvas-w screen.canvas-h)) (set pool (level.load screen)) (pool:flush) (pool:emit :load) diff --git a/game/src/colors.fnl b/game/src/colors.fnl index 9c6bd9b..4b0c315 100644 --- a/game/src/colors.fnl +++ b/game/src/colors.fnl @@ -14,6 +14,7 @@ :light-blue (color 0 185 190) :light-pink (color 255 176 163) :black [0 0 0] + :white [255 255 255] :black-half-tone [0 0 0 0.25] }) diff --git a/game/src/systems/camera.fnl b/game/src/systems/camera.fnl index 754aff0..ab2a1e9 100644 --- a/game/src/systems/camera.fnl +++ b/game/src/systems/camera.fnl @@ -29,6 +29,7 @@ (let [screen self.pool.data.screen canvas self.pool.data.canvas] ; use canvas (love.graphics.setCanvas canvas) + ; (love.graphics.setCanvas {: canvas :stencil true}) ; clear the screen (love.graphics.clear) (color.set-color :cream) diff --git a/game/src/systems/fog_of_war.fnl b/game/src/systems/fog_of_war.fnl index 0644c3f..036823e 100644 --- a/game/src/systems/fog_of_war.fnl +++ b/game/src/systems/fog_of_war.fnl @@ -4,9 +4,34 @@ (local levels (require "levels.fnl")) (local fow - { :cells [] }) + { :cells [] :canvas nil }) (lambda fow.load [self] + (set self.canvas (love.graphics.newCanvas 100 100)) + ; self.pool.data.screen.canvas-w self.pool.data.screen.canvas-h)) + ; (love.graphics.setCanvas {:canvas self.canvas :stencil true}) + ; (love.graphics.setCanvas self.canvas) + ; (love.graphics.push) + ; (love.graphics.origin) + ; (color.set-color :black) + ; (love.graphics.rectangle "fill" 50 50 300 100) + ; (color.set-color :white) + ; (love.graphics.rectangle "fill" 150 50 100 100) + ; (love.graphics.pop) + ; (love.graphics.setCanvas) + ; () + ; (fn draw-mask [] + ; (color.set-color :black) + ; (love.graphics.rectangle :fill 0 0 self.pool.data.screen.canvas-w self.pool.data.screen.canvas-h) + ; (color.set-color :white) + ; (love.graphics.circle :fill 300 300 150 150)) + + ; (love.graphics.stencil draw-mask :replace 1) + ; (love.graphics.setStencilTest :greater 0) + ; (color.set-color :dark-purple) + ; (love.graphics.rectangle :fill 0 0 self.pool.data.screen.canvas-w self.pool.data.screen.canvas-h) + ; (love.graphics.setStencilTest) + ; (love.graphics.draw self.canvas 0 0 0 self.pool.data.screen.scale self.pool.data.screen.scale) (let [tiles (. levels :levels self.pool.data.level-key :tiles) rows-of-tiles (length tiles) cols-of-tiles (length (. tiles 1)) @@ -26,9 +51,19 @@ (self.pool.data.bump-world:add cell cell.x cell.y 25 25)))) (lambda fow.draw80 [self] + (love.graphics.push) + (love.graphics.origin) + (love.graphics.setCanvas self.canvas) (color.set-color :dark-purple) - (each [_ cell (pairs self.cells)] - (when (= cell.hit false) - (love.graphics.rectangle :fill cell.x cell.y 25 25)))) + (love.graphics.rectangle "fill" 0 0 250 250) + (love.graphics.setColor 0 0 0 0) + (love.graphics.setBlendMode "replace") + (love.graphics.circle "fill" 25 25 20) + (love.graphics.setBlendMode "alpha") + (love.graphics.setCanvas self.pool.data.canvas) + (color.reset-color) + (love.graphics.draw self.canvas 50 50) + (love.graphics.pop) + ) fow