render the level art
This commit is contained in:
parent
d6f68bb3ba
commit
070ab245d7
1 changed files with 18 additions and 17 deletions
|
|
@ -1,8 +1,11 @@
|
|||
(local map-util (require "map-util.fnl"))
|
||||
(local levels (require "levels.fnl"))
|
||||
(local levels (. (require "levels.fnl") :levels))
|
||||
|
||||
(var player-art nil) ; 25x50 pixels each player is 25x25
|
||||
(var dust-sprite nil) ; 35x35 pixels
|
||||
(var walls-sprite nil)
|
||||
(var walls-batch nil)
|
||||
(var wall-quads nil)
|
||||
(local game-state {
|
||||
:player-pos [0 0]
|
||||
:player-dir :n ; n = north, s = south, e = east, w = west
|
||||
|
|
@ -28,12 +31,23 @@
|
|||
)
|
||||
)
|
||||
|
||||
|
||||
(fn love.load []
|
||||
(map-util:load)
|
||||
(love.window.setMode 600 640)
|
||||
|
||||
|
||||
(set walls-sprite (love.graphics.newImage "assets/walls.png"))
|
||||
(set walls-batch (love.graphics.newSpriteBatch walls-sprite 2500))
|
||||
(set wall-quads [])
|
||||
(let [(h w) (: walls-sprite :getDimensions)]
|
||||
(for [i 0 19 1]
|
||||
(table.insert wall-quads (love.graphics.newQuad (* i 25) 0 25 25 h w))))
|
||||
|
||||
(each [_ row (pairs (. levels :level01 :tiles))]
|
||||
(each [_ tile (pairs row)]
|
||||
(: walls-batch :add (. wall-quads (. tile :tile-id)) (. tile :x) (. tile :y))))
|
||||
|
||||
|
||||
(set player-art {
|
||||
:player-sprite (love.graphics.newImage "assets/player.png")
|
||||
:player1-quad (love.graphics.newQuad 0 0 25 25 50 25)
|
||||
|
|
@ -69,22 +83,9 @@ while 1 do love.event.push('stdin', io.read('*line')) end") :start))
|
|||
(love.graphics.rectangle "line" 50 50 500 500))
|
||||
|
||||
(fn draw-world []
|
||||
(love.graphics.setColor (unpack black))
|
||||
; (love.graphics.rectangle "fill" 50 50 500 500))
|
||||
(each [y cells (ipairs (. game-state :world))]
|
||||
(each [x cell (ipairs cells)]
|
||||
(case [(. cell :revealed) (. cell :type)]
|
||||
; [false _] (do
|
||||
; (love.graphics.setColor 1 1 1) ; reset color to white (no tinting)
|
||||
; (love.graphics.draw dust-sprite (+ 45 (* 25 (- x 1))) (+ 45 (* 25 (- y 1)))))
|
||||
[true :wall] (do
|
||||
(love.graphics.setColor (unpack black))
|
||||
(love.graphics.rectangle "fill" (+ 50 (* 25 (- x 1))) (+ 50 (* 25 (- y 1))) 25 25))
|
||||
(love.graphics.setColor 1 1 1) ; reset color to white (no tinting)
|
||||
(love.graphics.draw walls-batch)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
; (print (fennel.view game-state))
|
||||
(fn draw-player []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue