diff --git a/desktop/resources/bg5.png b/desktop/resources/bg5.png index 3d3d380b..fdcab050 100644 Binary files a/desktop/resources/bg5.png and b/desktop/resources/bg5.png differ diff --git a/desktop/resources/cursor.png b/desktop/resources/cursor.png index edfee0fc..fa375132 100644 Binary files a/desktop/resources/cursor.png and b/desktop/resources/cursor.png differ diff --git a/desktop/src-common/advent/core.clj b/desktop/src-common/advent/core.clj index fce96fc4..20450cd5 100644 --- a/desktop/src-common/advent/core.clj +++ b/desktop/src-common/advent/core.clj @@ -7,7 +7,7 @@ [advent.pathfind]) (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter])) -(def scale 4) +(def scale 2) (def +screen-width+ 320) (def +screen-height+ 240) (def +num-cursors+ 4) @@ -91,6 +91,12 @@ range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)] range))))) +(defn box-maker-fn [x1 y1 x2 y2] + (fn [x y] + (and + (< x1 x x2) + (< y1 y y2)))) + (defscreen main-screen :on-show (fn [screen entities] @@ -101,13 +107,20 @@ house (texture "house.png") overdirt (texture "overdirt.png") music (sound "outside-house.mp3") - _ (sound! music :loop)] + ;; _ (sound! music :loop) + ] { :cursor {:id "cursor" :cursor-index 0 } :background (assoc background :id "background" :x 0 :y 0 :collision (advent.pathfind/map-from-resource "pathfind-test-big.png") :baseline 0 + :mouse-overrides [{:mouse-in? (box-maker-fn 290 131 320 224) + :cursor-override 4} + {:mouse-in? (box-maker-fn 60 180 224 240) + :cursor-override 7} + {:mouse-in? (box-maker-fn 0 40 30 140) + :cursor-override 6}] :scale-fn (scaler-fn-with-baseline 110 0.10 1.10)) :house (assoc house :x 0 :y 0 @@ -128,6 +141,19 @@ :on-resize (fn [screen entities] (size! screen 320 240)) + :on-mouse-moved + (fn [screen [entities]] + (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] + (if-let [mouse-override (first (filter #((:mouse-in? %) x y) (get-in entities [:background :mouse-overrides])))] + (when (not (get-in entities [:cursor :override])) + (do (input! :set-cursor-image (cursor "cursor.png" (:cursor-override mouse-override)) 0 0) + (assoc-in entities [:cursor :override] true))) + + (when (get-in entities [:cursor :override]) + (do (input! :set-cursor-image (cursor "cursor.png" (get-in entities [:cursor :cursor-index])) 0 0) + (assoc-in entities [:cursor :override] false)))) + + )) :on-touch-down (fn [screen [entities]] (if (= (button-code :right) (:button screen))