saving and loading starting room.
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]))
|
||||
|
||||
@@ -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])))
|
||||
|
||||
@@ -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])))
|
||||
|
||||
@@ -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])))
|
||||
|
||||
@@ -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])))
|
||||
|
||||
@@ -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])))
|
||||
|
||||
@@ -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])))
|
||||
|
||||
@@ -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])))
|
||||
|
||||
@@ -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]]
|
||||
|
||||
Reference in New Issue
Block a user