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

@ -81,21 +81,7 @@
extract-pos (fn [tag] {:x (round-num-str (get-in tag [:attrs :x]))
:y (round-num-str (get-in tag [:attrs :y]))})]
{:player-1 (extract-pos player-1)
:player-2 (extract-pos player-2)})
;; {:tag :objectgroup,
;; :attrs {:id "2", :name "spawns"},
;; {:player-1 nil
;; :player-2 nil}
;; (vec (reduce (fn [acc tag]
;; (if (= (:tag tag) :object)
;; (conj acc
;; (hash-map
;; :name (get-in tag [:attrs :name])
;; :x (Math/round (Double/parseDouble (get-in tag [:attrs :x])))
;; :y (Math/round (Double/parseDouble (get-in tag [:attrs :y])))))
;; acc)) '() (:content (first (filter #(= (get-in % [:attrs :name]) "spawns") tags))))))))
}))
:player-2 (extract-pos player-2)})}))
(def levels {:levels {:level-001 (parse-map level-001-map-tmx)
:tutorial (parse-map tutorial-map-tmx)}
:colliders colliders})

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="right-down" width="50" height="50" tilewidth="25" tileheight="25" infinite="0" nextlayerid="4" nextobjectid="18">
<map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="right-down" width="50" height="50" tilewidth="25" tileheight="25" infinite="0" nextlayerid="5" nextobjectid="19">
<tileset firstgid="1" source="walls.tsx"/>
<tileset firstgid="21" source="objects.tsx"/>
<layer id="1" name="bg" width="50" height="50">
@ -32,15 +32,15 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,7,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,1,1,1,1,1,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,1,1,1,1,1,2147483658,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -76,4 +76,7 @@
<object id="15" name="controls" type="info_pad" x="550" y="1150" width="25" height="25"/>
<object id="16" name="controls" type="info_pad" x="675" y="1150" width="25" height="25"/>
</objectgroup>
<objectgroup id="4" name="Layer via Copy">
<object id="18" name="waiting_for_player2" type="info_pad" x="675" y="1025" width="25" height="25"/>
</objectgroup>
</map>

File diff suppressed because one or more lines are too long

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)