get hole in layer working. first step of fog of war
This commit is contained in:
parent
c10c03add0
commit
7432203d7b
4 changed files with 42 additions and 5 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue