From 7044605f61186bf6994507bf8151f577bf740657 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sun, 16 Aug 2026 19:39:24 +0700 Subject: [PATCH] editor-mode, draw when active, screen dim defs --- src/game.clj | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/game.clj b/src/game.clj index 925197f..7176239 100644 --- a/src/game.clj +++ b/src/game.clj @@ -3,22 +3,34 @@ [engine] [rl :as rl])) +(def screen-width 900) +(def screen-height 500) + (set! *warn-on-reflection* true) ;; (set! *unchecked-math* :warn-on-boxed) (defn init-game [config] - {:color-idx 0}) + {:editor-mode false + :color-idx 0}) (defn handle-game-input [config game] (when (rl/key-pressed? rl/key-r)) - (when (rl/mouse-button-down? rl/mouse-button-left)) - game) + (cond-> game + (rl/key-pressed? rl/key-space) + (update :editor-mode not))) (defn update-game [config game] + (if (:editor-mode game) + () + ()) 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] {:color-idx (:color-idx game)}) @@ -26,8 +38,8 @@ (defn -main [& _args] (engine/run-game! {:title "Siam Farmer" - :width 900 - :height 500 + :width screen-width + :height screen-height :config-path "game-config.edn" :init #'init-game :input #'handle-game-input @@ -36,5 +48,5 @@ :watch-fn #'watch-game})) (comment - ;; + (future (-main)) :-)