clean up and render player quad

This commit is contained in:
Travis Shears 2026-04-10 15:15:08 +02:00
parent b183853f77
commit 8f89883cb8
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
12 changed files with 16 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

View file

@ -1,7 +1,6 @@
(local map-util (require "map-util.fnl"))
(var player-01-sprite nil) ; 25x25 pixels
(var player-02-sprite nil) ; 25x25 pixels
(var player-art nil) ; 25x50 pixels each player is 25x25
(var dust-sprite nil) ; 35x35 pixels
(local game-state {
:player-pos [0 0]
@ -33,10 +32,16 @@
(map-util:load)
(love.window.setMode 600 640)
(set player-sprite (love.graphics.newImage "assets/player_001.png"))
(set player-art {
:player-sprite (love.graphics.newImage "assets/player.png")
:player1-quad (love.graphics.newQuad 0 0 25 25 50 25)
:player2-quad (love.graphics.newQuad 25 0 25 25 50 25)
})
(set dust-sprite (love.graphics.newImage "assets/dust_001.png"))
(start-level)
(print (fennel.view game-state))
; (print (fennel.view game-state))
;; start a thread listening on stdin
(: (love.thread.newThread "require('love.event')
while 1 do love.event.push('stdin', io.read('*line')) end") :start))
@ -68,9 +73,9 @@ while 1 do love.event.push('stdin', io.read('*line')) end") :start))
(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)))))
; [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))
@ -103,10 +108,11 @@ while 1 do love.event.push('stdin', io.read('*line')) end") :start))
:e 0
:w 25)
]
(love.graphics.draw player-sprite
(love.graphics.draw
(. player-art :player-sprite)
(. player-art :player1-quad)
(+ (* 25 player-x) x-offset 25)
(+ (* 25 player-y) y-offset 25)
rot 1.25 1.25)))
(+ (* 25 player-y) y-offset 25))))
(fn draw-ghost-grid []
(love.graphics.setColor (unpack black-half-tone))