Fix edn export and import, fix autotile and delete-tile functions, add rl collision api
This commit is contained in:
parent
79980f3da3
commit
a8178cbf52
@ -5,6 +5,7 @@
|
|||||||
(:require
|
(:require
|
||||||
[engine :as e]
|
[engine :as e]
|
||||||
[watch :as w]
|
[watch :as w]
|
||||||
|
[clojure.edn :as edn]
|
||||||
[rl :as rl]))
|
[rl :as rl]))
|
||||||
|
|
||||||
(def ^:const screen-width 1280)
|
(def ^:const screen-width 1280)
|
||||||
@ -45,6 +46,11 @@
|
|||||||
:layers (vec (repeatedly num-layers #(object-array (* rows cols))))
|
:layers (vec (repeatedly num-layers #(object-array (* rows cols))))
|
||||||
:current-layer 0
|
:current-layer 0
|
||||||
:current-tilemap 0
|
:current-tilemap 0
|
||||||
|
:atlases
|
||||||
|
;; (edn/read-string (slurp "./assets/Mushrooms, Flowers, Stones.edn"))
|
||||||
|
(let [path "./assets/Mushrooms, Flowers, Stones.edn"
|
||||||
|
atlas (edn/read-string (slurp path))]
|
||||||
|
[[:level-props (e/load-texture-once :level-props (:texture-path atlas)) (:selected-cells atlas)]])
|
||||||
;; TODO: When we cannot find the image, no errors are being reported. Likely because raylib is failing silently
|
;; TODO: When we cannot find the image, no errors are being reported. Likely because raylib is failing silently
|
||||||
;; TODO: How do we get Raylib to reload images on the fly
|
;; TODO: How do we get Raylib to reload images on the fly
|
||||||
:tilemaps
|
:tilemaps
|
||||||
@ -167,6 +173,7 @@
|
|||||||
(do-neighbors! layer at-row at-col
|
(do-neighbors! layer at-row at-col
|
||||||
(fn [l r c]
|
(fn [l r c]
|
||||||
(when (tile-at game l r c)
|
(when (tile-at game l r c)
|
||||||
|
(set-random-tile! game l r c)))))
|
||||||
|
|
||||||
(defn delete-tile! [game layer at-row at-col]
|
(defn delete-tile! [game layer at-row at-col]
|
||||||
(set-tile! game layer at-row at-col nil)
|
(set-tile! game layer at-row at-col nil)
|
||||||
@ -174,7 +181,6 @@
|
|||||||
(fn [l r c]
|
(fn [l r c]
|
||||||
(when (tile-at game l r c)
|
(when (tile-at game l r c)
|
||||||
(set-random-tile! game l r c)))))
|
(set-random-tile! game l r c)))))
|
||||||
(set-random-tile! game l r c)))))
|
|
||||||
|
|
||||||
(defn handle-game-input [config game]
|
(defn handle-game-input [config game]
|
||||||
(update-as-> [g game]
|
(update-as-> [g game]
|
||||||
|
|||||||
@ -228,6 +228,9 @@
|
|||||||
(defn draw-rectangle-lines-ex!* [rec line-thick color]
|
(defn draw-rectangle-lines-ex!* [rec line-thick color]
|
||||||
(draw-rectangle-lines-ex-raw!* rec (float line-thick) color))
|
(draw-rectangle-lines-ex-raw!* rec (float line-thick) color))
|
||||||
|
|
||||||
|
(defcfn collision-recs? "CheckCollisionRecs" [::rectangle ::rectangle] ::bool)
|
||||||
|
(defcfn collision-point-rec? "CheckCollisionPointRec" [::vector-2 ::rectangle] ::bool)
|
||||||
|
|
||||||
(def update-texture!*
|
(def update-texture!*
|
||||||
(ffi/make-downcall "UpdateTexture" [::texture ::mem/pointer] ::mem/void))
|
(ffi/make-downcall "UpdateTexture" [::texture ::mem/pointer] ::mem/void))
|
||||||
|
|
||||||
|
|||||||
@ -66,8 +66,7 @@
|
|||||||
(when-let [f (.getFile d)]
|
(when-let [f (.getFile d)]
|
||||||
(let [base-path (System/getProperty "user.dir")
|
(let [base-path (System/getProperty "user.dir")
|
||||||
full-path (str (.getDirectory d) f)]
|
full-path (str (.getDirectory d) f)]
|
||||||
(spit full-path (pr-str {:texture-path (str (.relativize (.toPath (io/file base-path))
|
(spit full-path (pr-str {:texture-path sprite-atlas-path
|
||||||
(.toPath (io/file full-path))))
|
|
||||||
:selected-cells (:selected-cells g)}))))
|
:selected-cells (:selected-cells g)}))))
|
||||||
game)
|
game)
|
||||||
#_(this should be to write the sprite sheet to some path))
|
#_(this should be to write the sprite sheet to some path))
|
||||||
@ -143,7 +142,6 @@
|
|||||||
:dragging (assoc g :drag-delta (let [{mx :x my :y} (rl/get-mouse-position)
|
:dragging (assoc g :drag-delta (let [{mx :x my :y} (rl/get-mouse-position)
|
||||||
{:keys [x y]} (:drag-start-pos g)]
|
{:keys [x y]} (:drag-start-pos g)]
|
||||||
[(- mx x) (- my y)]))))))
|
[(- mx x) (- my y)]))))))
|
||||||
(into #{[1 2]} [[1 2] [2 3]] )
|
|
||||||
|
|
||||||
(defn draw-sprite-atlas [_ {:keys [atlas atlas-pos drag-delta zoom drag-mode drag-start-pos current-mouse-pos selected-cells]}]
|
(defn draw-sprite-atlas [_ {:keys [atlas atlas-pos drag-delta zoom drag-mode drag-start-pos current-mouse-pos selected-cells]}]
|
||||||
(rl/clear-background!* rl/black)
|
(rl/clear-background!* rl/black)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user