flip tiles according to h-flip

This commit is contained in:
Travis Shears 2026-04-19 21:26:02 +02:00
parent bbbe7bfe8a
commit a457893d14
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
4 changed files with 11 additions and 32 deletions

View file

@ -71,7 +71,6 @@
(for [i 0 19 1]
(table.insert walls.quads (love.graphics.newQuad (* i 25) 0 25 25 w h))))
;; fill batch
;;
(each [_ row (pairs (. levels :levels level-key :tiles))]
(each [_ tile (pairs row)]
(let [
@ -82,7 +81,7 @@
(if (and (> id 0) (< id 21)) ;; 1-20 are wall tiles
(do
; (print (fennel.view {:quad (. walls.quads id) : x : y : id}))
(walls.batch:add (. walls.quads id) x y)
(walls.batch:add (. walls.quads id) (if tile.h-flip (+ x 25) x) y 0 (if tile.h-flip -1 1) 1)
(each [_ collider (pairs colliders)]
(bump-world:add {: x : y :name :wall :behavior :block} (+ x collider.x) (+ y collider.y) collider.width collider.height)
(table.insert
@ -127,16 +126,7 @@
(let [(w h) (objects.sprite:getDimensions)]
(set objects.quads.charging-pad (love.graphics.newQuad 0 0 25 25 w h))
(set objects.quads.charging-pad-active (love.graphics.newQuad 50 0 25 25 w h))
(set objects.quads.charging-station (love.graphics.newQuad 25 0 25 25 w h)))
(each [_ row (pairs (. levels :levels level-key :tiles))]
(each [_ tile (pairs row)]
(let [
x tile.x
y tile.y
id tile.tile-id]
(when (> id 20) ;; 21+ are object tiles
(when (= id 22) (create-charging-station x y)))))))
(set objects.quads.charging-station (love.graphics.newQuad 25 0 25 25 w h))))
(fn load-player []
(set player.battery 100)