editor-mode, draw when active, screen dim defs

This commit is contained in:
Joseph Ferano 2026-08-16 19:39:24 +07:00
parent a44a296296
commit 7044605f61

View File

@ -3,22 +3,34 @@
[engine] [engine]
[rl :as rl])) [rl :as rl]))
(def screen-width 900)
(def screen-height 500)
(set! *warn-on-reflection* true) (set! *warn-on-reflection* true)
;; (set! *unchecked-math* :warn-on-boxed) ;; (set! *unchecked-math* :warn-on-boxed)
(defn init-game [config] (defn init-game [config]
{:color-idx 0}) {:editor-mode false
:color-idx 0})
(defn handle-game-input [config game] (defn handle-game-input [config game]
(when (rl/key-pressed? rl/key-r)) (when (rl/key-pressed? rl/key-r))
(when (rl/mouse-button-down? rl/mouse-button-left)) (cond-> game
game) (rl/key-pressed? rl/key-space)
(update :editor-mode not)))
(defn update-game [config game] (defn update-game [config game]
(if (:editor-mode game)
()
())
game) game)
(defn draw-game [config game] (defn draw-game [config game]
(rl/clear-background!* rl/cornflower-blue)) (rl/clear-background!* rl/cornflower-blue)
(when (:editor-mode game)
(rl/draw-rectangle!* 0 0 screen-width screen-height (rl/color-seg 0 0 0 100))
(rl/draw-rectangle!* (/ screen-width 2) (/ screen-height 2) 100 100 rl/white)
(rl/draw-text!* "EDIT MODE" (- screen-width 100) 10 16 rl/green)))
(defn watch-game [config game] (defn watch-game [config game]
{:color-idx (:color-idx game)}) {:color-idx (:color-idx game)})
@ -26,8 +38,8 @@
(defn -main [& _args] (defn -main [& _args]
(engine/run-game! (engine/run-game!
{:title "Siam Farmer" {:title "Siam Farmer"
:width 900 :width screen-width
:height 500 :height screen-height
:config-path "game-config.edn" :config-path "game-config.edn"
:init #'init-game :init #'init-game
:input #'handle-game-input :input #'handle-game-input
@ -36,5 +48,5 @@
:watch-fn #'watch-game})) :watch-fn #'watch-game}))
(comment (comment
;; (future (-main))
:-) :-)