diff --git a/desktop/project.clj b/desktop/project.clj index 51778ae5..623153c2 100644 --- a/desktop/project.clj +++ b/desktop/project.clj @@ -16,7 +16,7 @@ #_[play-clj "0.3.9"] [org.clojure/data.priority-map "0.0.5"] [org.clojure/core.async "0.1.338.0-5c5012-alpha"]] - + :repl-options {:init-ns advent.core} :source-paths ["src" "src-common"] :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"] :aot [advent.core.desktop-launcher] diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 72c8bdd2..2a9325a2 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -413,7 +413,8 @@ old-music (get-in entities [:room :music]) entities (-> entities (assoc-in [:room] (get-in entities [:rooms new-background])) - (assoc-in [:room :entities :ego] ego)) + (assoc-in [:room :entities :ego] ego) + (assoc-in [:state :last-room] new-background)) new-music (get-in entities [:room :music]) apply-state (get-in entities [:room :apply-state]) entities (if apply-state diff --git a/desktop/src-common/advent/screens/rooms/behind_house.clj b/desktop/src-common/advent/screens/rooms/behind_house.clj index 03454cf6..1e264466 100644 --- a/desktop/src-common/advent/screens/rooms/behind_house.clj +++ b/desktop/src-common/advent/screens/rooms/behind_house.clj @@ -76,4 +76,5 @@ entities) (if (actions/has-one-of? entities [:stick :cat-toy]) (update-in entities [:room :entities] #(dissoc % :stick)) - entities))))) + entities))) + :start-pos [172 122])) diff --git a/desktop/src-common/advent/screens/rooms/cat_tree.clj b/desktop/src-common/advent/screens/rooms/cat_tree.clj index 95e34b29..344c3908 100644 --- a/desktop/src-common/advent/screens/rooms/cat_tree.clj +++ b/desktop/src-common/advent/screens/rooms/cat_tree.clj @@ -77,4 +77,5 @@ (as-> entities entities (if (actions/has-item? entities :certificate) (update-in entities [:room :entities] #(dissoc % :cat)) - entities)))))) + entities))) + :start-pos [203 1]))) diff --git a/desktop/src-common/advent/screens/rooms/inside_antique.clj b/desktop/src-common/advent/screens/rooms/inside_antique.clj index 1602e959..f28d9e13 100644 --- a/desktop/src-common/advent/screens/rooms/inside_antique.clj +++ b/desktop/src-common/advent/screens/rooms/inside_antique.clj @@ -144,4 +144,5 @@ (actions/talk entities :shopkeep "You brat! You ate the last mint.") (actions/talk entities :shopkeep "Since you ate the last one, you have to go tell Gandarf to bring me some more."))))))} :collision "inside-antique/collision.png" - :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.50)))) + :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.50) + :start-pos [222 3]))) diff --git a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj index 7fac75cc..f460ea46 100644 --- a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj +++ b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj @@ -152,4 +152,5 @@ (as-> entities entities (if (actions/has-item? entities :ladder) (update-in entities [:room :entities] #(dissoc % :ladder)) - entities)))))) + entities))) + :start-pos [300 55]))) diff --git a/desktop/src-common/advent/screens/rooms/inside_castle.clj b/desktop/src-common/advent/screens/rooms/inside_castle.clj index ea2a4912..ee70d179 100644 --- a/desktop/src-common/advent/screens/rooms/inside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/inside_castle.clj @@ -171,4 +171,5 @@ (as-> entities entities (if (actions/has-item? entities :ladder) (update-in entities [:room :entities] #(dissoc % :ladder)) - entities)))))) + entities))) + :start-pos [245 90]))) diff --git a/desktop/src-common/advent/screens/rooms/inside_house.clj b/desktop/src-common/advent/screens/rooms/inside_house.clj index 855aeb02..c377738a 100644 --- a/desktop/src-common/advent/screens/rooms/inside_house.clj +++ b/desktop/src-common/advent/screens/rooms/inside_house.clj @@ -87,4 +87,5 @@ (as-> entities entities (if (actions/has-one-of? entities [:flask-1 :flask-1-with-cream-of-mushroom :flask-1-strength :flask-1-with-mushrooms :flask-1-with-milk]) (update-in entities [:room :entities] #(dissoc % :flask)) - entities)))))) + entities))) + :start-pos [237 0]))) diff --git a/desktop/src-common/advent/screens/rooms/outside_castle.clj b/desktop/src-common/advent/screens/rooms/outside_castle.clj index fd0dc1fe..8bec5110 100644 --- a/desktop/src-common/advent/screens/rooms/outside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/outside_castle.clj @@ -128,4 +128,5 @@ (actions/talk entities :ego "Eww! He slobbered on my hand.") (actions/give entities :slobber))})} :collision "outside-castle/collision.png" - :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)))) + :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00) + :start-pos [310 80]))) diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index fea1133e..3f8898d4 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -203,4 +203,5 @@ (as-> entities entities (if (get-in entities [:state :coaxed-sheep?]) (update-in entities [:room :entities :sheep] #(assoc % :x 95 :y 150 :baseline 40)) - entities)))))) + entities))) + :start-pos [0 80]))) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 6f16f486..026445a0 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -78,7 +78,7 @@ entities)))) -(defn get-ego [screen] +(defn get-ego [screen start-pos] (let [player-sheet (texture! (texture "player.png") :split 18 36) talk-sheet (texture! (texture "ego/talk.png") :split 18 36) stand-sheet (texture! (texture "ego/stand.png") :split 18 36) @@ -135,7 +135,7 @@ [:fire 1] (utils/flip fire-1-anim) [:fire 2] (utils/flip fire-2-anim) [:fire 3] (utils/flip fire-3-anim)} - :baseline 95 + :baseline (- 240 (last start-pos)) :facing :right :origin-x 9 :origin-y 0 @@ -166,7 +166,7 @@ :ego "'Not more than that do drink,'" :ego "'Or you'll push your body to the brink.'")) nil)) - :x 150 :y 95 + :x (first start-pos) :y (last start-pos) :id "ego"}] (actions/start-animation screen (merge (animation->texture screen (:stand (:right ego))) ego) @@ -203,6 +203,7 @@ (music! snd :play)) (defn stop-sound [snd] + (println "here") (music! snd :stop)) (defn make-music [r] @@ -213,6 +214,7 @@ (utils/load) {:object nil :active? true + :last-room :outside-house :inventory [] :clues #{} :mints-eaten 0})) @@ -246,12 +248,15 @@ :last :main :override nil} :all-items (assoc items/items :object nil) - :room (assoc-in (:outside-house rooms) - [:entities :ego] (get-ego screen)) + :room (as-> (get rooms (:last-room (get-state))) room + (assoc-in room [:entities :ego] (get-ego screen (:start-pos room)))) :inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000 :mouse-in? (zone/box 278 0 320 42)) :fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)}] - ((get-in entities [:room :apply-state]) entities)))) + + (if-let [apply-state (get-in entities [:room :apply-state])] + (apply-state entities) + entities)))) :on-render (fn [screen [entities]] @@ -272,12 +277,12 @@ :on-resize (fn [screen entities] (size! screen 320 240)) - :on-hide (fn [screen entities] - (doall (->> (get-in entities [:room :entities :musics]) - vals - (map identity) - (map stop-sound) - ))) + :on-hide (fn [screen [entities]] + (println (keys entities)) + (doseq [snd (->> (doto (get-in entities [:musics]) println) + vals + (filter identity))] + (stop-sound snd))) :on-mouse-moved (fn [screen [entities]]