diff --git a/desktop/resources/cursor.png b/desktop/resources/cursor.png index 10516fd9..ad16cbc8 100644 Binary files a/desktop/resources/cursor.png and b/desktop/resources/cursor.png differ diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 87094b0b..bc88fd9d 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -24,29 +24,17 @@ (cursor-override [this])) (defprotocol IInteractable - (interact [this screen entities cursor location])) + (interact [this screen entities location])) (def default-interaction (reify IInteractable - (interact [_ screen entities cursor [x y] ] - (case cursor - :walk (actions/get-script - (actions/walk-to entities :ego [x y])) - :look (actions/get-script - (actions/talk entities - :ego - "Looks pretty uninteresting to me.")) - :touch (actions/get-script - (actions/talk entities :ego - "Can't do anything with it.")) - :talk (actions/get-script - (actions/talk entities :ego - "It's not much of a conversationalist.")))))) + (interact [_ screen entities [x y]] + (actions/get-script + (actions/walk-to entities :ego [x y]))))) -(def +next-cursor+ (into {} (map vector [:walk :touch :look :talk] (drop 1 (cycle [:walk :touch :look :talk]))))) -(def +all-cursors+ [:walk :touch :look :talk :right :down :left :up]) +(def +all-cursors+ [:main :touch :look :talk :right :down :left :up]) (defn cursor [filename which] @@ -61,17 +49,10 @@ 0 0 target-width target-height) resized )) -(defn right-click [screen entities] - (let [entities (update-in entities [:cursor] #(assoc % :current (+next-cursor+ (:current %))))] - (input! :set-cursor-image (cursor "cursor.png" (get-in entities [:cursor :current])) 0 0) - entities)) - - (defn left-click [screen entities] (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)}) interaction (first (filter #(mouse-in? % [x y]) (get-in entities [:background :interactions]))) - current-cursor (get-in entities [:cursor :current]) cursor-override (get-in entities [:cursor :override]) ;; TODO - hacky way of resetting queue entities (if-let [current-action (get-in entities [:actions :current])] @@ -79,10 +60,10 @@ :actions {:channel (chan) :current nil :started? false}) entities) script (or (when cursor-override - (interact cursor-override screen entities current-cursor [x y])) + (interact cursor-override screen entities [x y])) (when interaction - (interact interaction screen entities current-cursor [x y])) - (interact default-interaction screen entities current-cursor [x y]))] + (interact interaction screen entities [x y])) + (interact default-interaction screen entities [x y]))] (script (get-in entities [:actions :channel])) entities)) @@ -130,7 +111,7 @@ :on-show (fn [screen entities] (update! screen :renderer (stage) :camera (orthographic)) - (let [_ (input! :set-cursor-image (cursor "cursor.png" :walk) 0 0) + (let [_ (input! :set-cursor-image (cursor "cursor.png" :main) 0 0) sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21) sheep (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 9 10 (repeat 25 11) (repeat 15 12)])] (aget sheep-sheet 0 i))) @@ -146,7 +127,7 @@ :channel (chan) :current nil :started? false} - :cursor {:id "cursor" :current :walk } + :cursor {:id "cursor" :current :main } :sheep (assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep) :background (assoc {} :collision (advent.pathfind/map-from-resource "pathfind-test-big.png") @@ -156,7 +137,7 @@ (mouse-in? [_ location] (apply (zone/box 300 131 320 224) location)) IInteractable - (interact [_ _ entities _ _] + (interact [_ _ entities _] (actions/get-script (actions/walk-to entities :ego [319 160]))) ICursorOverridable @@ -166,7 +147,7 @@ (mouse-in? [_ location] (apply (zone/box 60 180 224 240) location)) IInteractable - (interact [_ _ entities _ _] + (interact [_ _ entities _] (actions/get-script (actions/walk-to entities :ego [137 204]))) ICursorOverridable @@ -176,7 +157,7 @@ (mouse-in? [_ location] (apply (zone/box 0 40 20 140) location)) IInteractable - (interact [_ _ entities _ _] + (interact [_ _ entities _] (actions/get-script (actions/walk-to entities :ego [0 80]))) ICursorOverridable @@ -186,49 +167,31 @@ (mouse-in? [_ location] (apply (zone/box 258 100 281 160) location)) IInteractable - (interact [_ _ entities cursor _] - (case cursor - :look - (actions/get-script - (actions/talk entities :ego (str "The last time I went through that door, Fangald turned me into a frog."))) - - :touch - (actions/get-script - (actions/walk-to entities :ego [262 88]) - (actions/talk entities :ego (str "Anyone home?"))) - nil))) + (interact [_ _ entities _] + (actions/get-script + (actions/walk-to entities :ego [262 88]) + (actions/talk entities :ego (str "Anyone home?"))))) (reify IMouseIn (mouse-in? [_ location] (apply (zone/box 274 55 305 88) location)) IInteractable - (interact [_ screen entities cursor _] - (case cursor - :look - (actions/get-script - (actions/talk entities :ego (str "It's the coolest sword I've ever seen!"))) - :touch - (actions/get-script - (actions/walk-to entities :ego [290 66]) - (actions/talk entities :ego "Maybe I can pull it out.")) - nil))) + (interact [_ screen entities _] + (actions/get-script + (actions/talk entities :ego (str "It's the coolest sword I've ever seen!")) + (actions/walk-to entities :ego [290 66]) + (actions/talk entities :ego "Maybe I can pull it out.")))) (reify IMouseIn (mouse-in? [_ location] (apply (zone/box 38 160 71 181) location)) IInteractable - (interact [_ screen entities cursor _] - (case cursor - :look - (actions/get-script - (actions/talk entities :ego (str "Aww, it's a cute little sheep."))) - :touch - (actions/get-script - (if ((get-in entities [:ego :inventory]) :wool) - (actions/talk entities :ego "The sheep has given me enough wool.") - (do (actions/give entities :ego :wool) - (actions/talk entities :ego "I guess his wool is shedding.")))) - nil)))] + (interact [_ screen entities _] + (actions/get-script + (if ((get-in entities [:ego :inventory]) :wool) + (actions/talk entities :ego "The sheep has given me enough wool.") + (do (actions/give entities :ego :wool) + (actions/talk entities :ego "I guess his wool is shedding."))))))] :scale-fn (scaler-fn-with-baseline 110 0.10 1.00) :layers [(assoc background :x 0 :y 0 :baseline 0) (assoc house :x 0 :y 0 :baseline 122) @@ -266,10 +229,8 @@ (assoc-in entities [:cursor :override] mouse-override))) (when (get-in entities [:cursor :override]) - (do (input! :set-cursor-image (cursor "cursor.png" (get-in entities [:cursor :current])) 0 0) + (do (input! :set-cursor-image (cursor "cursor.png" :main) 0 0) (assoc-in entities [:cursor :override] nil)))))) :on-touch-down (fn [screen [entities]] - (if (= (button-code :right) (:button screen)) - (right-click screen entities) - (left-click screen entities)))) + (left-click screen entities)))