diff --git a/desktop/resources/inside-house/background.png b/desktop/resources/inside-house/background.png index e19da54e..b92cc869 100644 Binary files a/desktop/resources/inside-house/background.png and b/desktop/resources/inside-house/background.png differ diff --git a/desktop/resources/wizard/stand.png b/desktop/resources/wizard/stand.png new file mode 100644 index 00000000..ce64fc19 Binary files /dev/null and b/desktop/resources/wizard/stand.png differ diff --git a/desktop/resources/wizard/talk.png b/desktop/resources/wizard/talk.png new file mode 100644 index 00000000..f3c1169a Binary files /dev/null and b/desktop/resources/wizard/talk.png differ diff --git a/desktop/resources/wizard/talk.pxa/0.pxi b/desktop/resources/wizard/talk.pxa/0.pxi new file mode 100644 index 00000000..44daed7f Binary files /dev/null and b/desktop/resources/wizard/talk.pxa/0.pxi differ diff --git a/desktop/resources/wizard/talk.pxa/1.pxi b/desktop/resources/wizard/talk.pxa/1.pxi new file mode 100644 index 00000000..a47f307a Binary files /dev/null and b/desktop/resources/wizard/talk.pxa/1.pxi differ diff --git a/desktop/resources/wizard/talk.pxa/2.pxi b/desktop/resources/wizard/talk.pxa/2.pxi new file mode 100644 index 00000000..ad4e4cbc Binary files /dev/null and b/desktop/resources/wizard/talk.pxa/2.pxi differ diff --git a/desktop/resources/wizard/talk.pxa/3.pxi b/desktop/resources/wizard/talk.pxa/3.pxi new file mode 100644 index 00000000..1a6bdecd Binary files /dev/null and b/desktop/resources/wizard/talk.pxa/3.pxi differ diff --git a/desktop/resources/wizard/talk.pxa/CelData.plist b/desktop/resources/wizard/talk.pxa/CelData.plist new file mode 100644 index 00000000..f6263f12 --- /dev/null +++ b/desktop/resources/wizard/talk.pxa/CelData.plist @@ -0,0 +1,22 @@ + + + + + + duration + 0.20000000298023224 + + + duration + 0.20000000298023224 + + + duration + 0.20000000298023224 + + + duration + 0.20000000298023224 + + + diff --git a/desktop/src-common/advent/action_test.clj b/desktop/src-common/advent/action_test.clj deleted file mode 100644 index 0abf0427..00000000 --- a/desktop/src-common/advent/action_test.clj +++ /dev/null @@ -1,93 +0,0 @@ -(ns advent.action-test) - -(defprotocol IAction - (begin [this state]) - (done? [this state]) - (continue [this state])) - - -(defmacro do-actions [name & forms] - `(vector ~@(for [form forms] - `(fn [~name] - ~form)))) - -(defn walk-to [who & targets ] - (for [[target-x target-y] targets] - (fn [state] - (reify - IAction - (begin [this state] (println "Starting Walking") state) - (continue [this {:keys [x y] :as state}] - (println "Continue Walking from" x y) - (Thread/sleep 500) - (assoc state :x (inc x) :y (inc y))) - (done? [this {:keys [x y]} ] - (and (= x target-x) - (= y target-y))))))) - -(defn talk [who text] - (reify - IAction - (begin [this state] - (println "Speaking:" text) - (assoc state :time 0)) - (continue [this state] - (Thread/sleep 200) - (assoc state :time (inc (:time state)))) - (done? [this {:keys [time]}] - (< 3 time)))) - -(defn give-item [item] - (reify - IAction - (begin [this state] - (println "Receiving item:" item) - (update-in state [:items] #(conj % item))) - (continue [this state] - state) - (done? [this state] - true))) - - -(defn walk-to [who & targets ] - (for [[target-x target-y] targets] - (fn [state] - (reify - IAction - (begin [this state] (println "Starting Walking to" target-x target-y) state) - (continue [this {:keys [x y] :as state}] - (println "Continue Walking from" x y) - (Thread/sleep 500) - (assoc state :x (inc x) :y (inc y))) - (done? [this {:keys [x y]} ] - (and (>= x target-x) - (>= y target-y))))))) - -(defn get-script [] - (let [random-loc (+ 3 (rand-int 10))] - (do-actions state - (if (= 1 (rand-int 2)) - (give-item :gold) - (give-item :candy)) - (walk-to :ego [3 3] [random-loc random-loc] ) - (if ((:items state) :gold) - (talk :ego "I have enough money to buy something") - (talk :ego "I'm broke."))))) - -(defn test-run [] - (let [state {:x 0 :y 0 :time 0 :items #{}} - actions (get-script)] - (loop [actions actions - state state - started? false] - (when (seq actions) - (let [step ((first actions) state)] - (if (sequential? step) - (recur (concat step (rest actions)) state false) - (let [state (if started? - state - (begin step state)) - state (continue step state)] - (if (done? step state) - (recur (rest actions) state false) - (recur actions state true))))))))) diff --git a/desktop/src-common/advent/action_test2.clj b/desktop/src-common/advent/action_test2.clj deleted file mode 100644 index 4fc7514b..00000000 --- a/desktop/src-common/advent/action_test2.clj +++ /dev/null @@ -1,99 +0,0 @@ -(ns advent.action-test2 - (:require [clojure.core.async :refer [put! ! chan go thread take! alts!!]])) - -(defprotocol IAction - (begin [this state]) - (done? [this state]) - (continue [this state]) - (terminate [this state])) - - - -(defn talk [action-channel who text] - (let [c (chan)] - (put! action-channel - (reify - IAction - (begin [this state] - (println "Speaking:" text) - (assoc state :time 0)) - (continue [this state] - (Thread/sleep 200) - (assoc state :time (inc (:time state)))) - (done? [this {:keys [time]}] - (< 3 time)) - (terminate [this state] - (put! c state) - state))) - (= x target-x) - (>= y target-y))) - (terminate [this state] - (put! c state) - state)))) - (screen screen {:x (:input-x screen) :y (:input-y screen)})] + (when (seq entities) + (when (< y (* 20 (count entities))) + (run! @(resolve 'advent.screens.scene/scene) :on-start-script :script (:result-script (entities (int (/ y 20))))) + {})))) + + :on-resize (fn [screen entities] + (size! screen 1280 960))) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 38cece3b..ff5745e3 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -155,18 +155,49 @@ (aget peddler-sheet 0 i))) peddler-stand (animation 0.2 (for [i (flatten [(repeat 5 0) 6])] (aget peddler-sheet 0 i))) - wizard (texture "wizard.png") - _ (texture! wizard :flip true false)] + wizard-sheet (texture! (texture "wizard/talk.png") :split 20 46) + wizard-stand (animation 0.2 (for [i (flatten [(repeat 10 0) 1])] + (aget wizard-sheet 0 i))) + wizard-talk (animation 0.2 (for [i [0 2 0 2 1 2 0 3 0 2 0 1 0 2]] + (aget wizard-sheet 0 i)))] {:inside-house (make-background :interactions {:down-dir {:box [151 0 320 20] :script (actions/get-script entities (actions/walk-to entities :ego [237 1]) (actions/transition-background entities :outside-house [262 88])) - :cursor :down}} + :cursor :down} + :wizard {:box [228 80 248 126] + :script (actions/get-script entities + (actions/talk entities :ego "Hello there Fangald!") + (actions/talk entities :wizard "Oh no, not you again!") + (actions/present-choices entities "You're not my friend, Mr. Fangald?" + (actions/get-script entities + (actions/talk entities :ego "You're not my friend, Mr. Fangald?") + (actions/talk entities :wizard "No, you are a rascally little boy who is nothing but a cheat!") + (actions/present-choices entities + "Oh, come on, I'm not that bad." + (actions/get-script entities + (actions/talk entities :ego "Oh, come on, I'm not that bad.") + (actions/talk entities :wizard "Yes you are. Shoo!")) + "I'm sorry." + (actions/get-script entities + (actions/talk entities :ego "I'm sorry") + (actions/talk entities :wizard "That's better. Now scram.")) + )) + "Yes, it's me!" + (actions/get-script entities + (actions/talk entities :ego "Yes, it's me!") + (actions/talk entities :wizard "Great, just great. Leave me alone."))))}} :layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0) (assoc (texture "inside-house/desk.png") :x 0 :y 0 :baseline 200) (assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)] - :entities {:wizard (assoc wizard :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75)} + :entities {:wizard (actions/start-animation screen (assoc (animation->texture screen wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75 + :left {:talk (flip wizard-talk) + :stand (flip wizard-stand)} + :right {:talk wizard-talk + :stand wizard-stand} + :facing :left) + :stand)} :collision "inside-house/collision.png" :scale-fn (scaler-fn-with-baseline 110 0.10 1.75)) :outside-house @@ -312,7 +343,7 @@ (update! screen :renderer (stage) :camera (orthographic)) (let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0) music (sound "town-music.mp3") - _ (sound! music :loop 0.20) + ;; _ (sound! music :loop 0.20) backgrounds (backgrounds screen)] {:backgrounds backgrounds :actions {:object nil @@ -361,4 +392,8 @@ (if (= (button-code :right) (:button screen)) (assoc-in entities [:cursor :current] :main) - (left-click screen entities)))) + (left-click screen entities))) + + :on-start-script (fn [{:keys [script]} [entities] ] + (script entities) + entities))