sound closeness
This commit is contained in:
@@ -257,7 +257,7 @@
|
|||||||
steer-sheet (texture! (texture "outside-castle/steer.png") :split 50 35)
|
steer-sheet (texture! (texture "outside-castle/steer.png") :split 50 35)
|
||||||
steer-stand (animation 0.2 (for [i [0 0 0 0 0 0 0 0 0 1 0 2 0 1 0 2 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 0 0 0 0]]
|
steer-stand (animation 0.2 (for [i [0 0 0 0 0 0 0 0 0 1 0 2 0 1 0 2 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 0 0 0 0]]
|
||||||
(aget steer-sheet 0 i)))
|
(aget steer-sheet 0 i)))
|
||||||
flies-stand (utils/make-anim "outside-castle/flies.png" [15 15] 0.075 [0 1 2 1])]
|
flies-stand (utils/make-anim "outside-castle/flies.png" [15 15] 0.075 (flatten (repeat 2 [0 1 2 1])))]
|
||||||
(rooms/make :music {:day :town-2 :night :night :sunrise :night}
|
(rooms/make :music {:day :town-2 :night :night :sunrise :night}
|
||||||
:interactions
|
:interactions
|
||||||
{:right-dir {:box [300 40 320 140]
|
{:right-dir {:box [300 40 320 140]
|
||||||
@@ -295,7 +295,7 @@
|
|||||||
:sunrise [(assoc (texture "outside-castle/background-sunrise.png") :x 0 :y 0 :baseline 0)]}
|
:sunrise [(assoc (texture "outside-castle/background-sunrise.png") :x 0 :y 0 :baseline 0)]}
|
||||||
:entities {:peddler (actions/start-animation screen
|
:entities {:peddler (actions/start-animation screen
|
||||||
(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil
|
(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil
|
||||||
:anim-sound-frames {peddler-stand {23 :scratch}}
|
:anim-sound-frames {peddler-stand {23 [:scratch 1.0]}}
|
||||||
:scratch (sound "scratch.ogg")
|
:scratch (sound "scratch.ogg")
|
||||||
:talk peddler-talk :stand peddler-stand
|
:talk peddler-talk :stand peddler-stand
|
||||||
:talk-color (color 1.0 0.9 0.4 1.0)
|
:talk-color (color 1.0 0.9 0.4 1.0)
|
||||||
@@ -360,6 +360,7 @@
|
|||||||
:anim flies-stand
|
:anim flies-stand
|
||||||
:anim-start 0
|
:anim-start 0
|
||||||
:baseline 240
|
:baseline 240
|
||||||
|
:sound (sound "outside-castle/flies.ogg")
|
||||||
:scripts {:sack-lunch (actions/get-script entities
|
:scripts {:sack-lunch (actions/get-script entities
|
||||||
(actions/walk-to entities :ego [168 150] :face :right)
|
(actions/walk-to entities :ego [168 150] :face :right)
|
||||||
(actions/talk entities :ego "Maybe I can catch some of these flies.")
|
(actions/talk entities :ego "Maybe I can catch some of these flies.")
|
||||||
@@ -368,7 +369,8 @@
|
|||||||
(actions/talk entities :ego "I think it's working!")
|
(actions/talk entities :ego "I think it's working!")
|
||||||
(actions/play-animation entities :ego :squat)
|
(actions/play-animation entities :ego :squat)
|
||||||
(actions/give entities :flies)
|
(actions/give entities :flies)
|
||||||
(actions/talk entities :ego "Hopefully they won't fly out of my backpack."))})}
|
(actions/talk entities :ego "Hopefully they won't fly out of my backpack."))}
|
||||||
|
:anim-sound-frames {flies-stand {0 [:sound 0.33]}})}
|
||||||
:note (rooms/make-entity :note (assoc (texture "outside-castle/note.png")
|
:note (rooms/make-entity :note (assoc (texture "outside-castle/note.png")
|
||||||
:x 198 :y 66 :baseline 174
|
:x 198 :y 66 :baseline 174
|
||||||
:script (actions/get-script entities
|
:script (actions/get-script entities
|
||||||
|
|||||||
@@ -295,10 +295,10 @@
|
|||||||
nil))
|
nil))
|
||||||
:x (first start-pos) :y (last start-pos)
|
:x (first start-pos) :y (last start-pos)
|
||||||
:id "ego"}
|
:id "ego"}
|
||||||
ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 :step-sound-1
|
ego (assoc ego :anim-sound-frames {(get-in ego [:left :walk]) {2 [:step-sound-1 1.0]
|
||||||
6 :step-sound-2}
|
6 [:step-sound-2 0.8]}
|
||||||
(get-in ego [:right :walk]) {2 :step-sound-1
|
(get-in ego [:right :walk]) {2 [:step-sound-1 1.0]
|
||||||
6 :step-sound-2}}
|
6 [:step-sound-2 0.8]}}
|
||||||
:anim-merges {(get-in ego [:right :shock]) {:origin-x 15}
|
:anim-merges {(get-in ego [:right :shock]) {:origin-x 15}
|
||||||
:default {:origin-x 9}})]
|
:default {:origin-x 9}})]
|
||||||
(actions/start-animation screen
|
(actions/start-animation screen
|
||||||
@@ -370,11 +370,22 @@
|
|||||||
:seen-intro? false}))
|
:seen-intro? false}))
|
||||||
|
|
||||||
(defn play-key-sounds [entities]
|
(defn play-key-sounds [entities]
|
||||||
(doseq [{:keys [previous-frame-index current-frame-index anim-sound-frames anim] :as e} (vals entities)]
|
(doseq [[target {:keys [previous-frame-index current-frame-index anim-sound-frames anim x y] :as e}] entities]
|
||||||
(when (and (not= previous-frame-index current-frame-index)
|
(when (and (not= previous-frame-index current-frame-index)
|
||||||
((set (keys anim-sound-frames)) anim))
|
((set (keys anim-sound-frames)) anim))
|
||||||
(when-let [snd (get-in anim-sound-frames [anim current-frame-index])]
|
(when-let [[snd vol-scale] (get-in anim-sound-frames [anim current-frame-index])]
|
||||||
(sound! (snd e) :play (* (/ (get-in entities [:ego :scale-x]) 1.5) 0.75))))))
|
(let [vol (if (= target :ego)
|
||||||
|
(* (/ (get-in entities [:ego :scale-x]) 1.5) 0.75)
|
||||||
|
(max 0.0
|
||||||
|
(- 1.0 (/ (utils/dist x y
|
||||||
|
(get-in entities [:ego :x])
|
||||||
|
(get-in entities [:ego :y])
|
||||||
|
:y-sign 2.0
|
||||||
|
:x-sign (/ 1.0 (get-in entities [:ego :scale-x])))
|
||||||
|
175.0))))
|
||||||
|
vol (* vol vol-scale)]
|
||||||
|
(when (> vol 0.05)
|
||||||
|
(sound! (snd e) :play vol)))))))
|
||||||
|
|
||||||
|
|
||||||
(defscreen scene
|
(defscreen scene
|
||||||
|
|||||||
@@ -62,9 +62,11 @@
|
|||||||
(.r))]
|
(.r))]
|
||||||
(+ (* percent-complete (- maximum-size minimum-size)) minimum-size)))))
|
(+ (* percent-complete (- maximum-size minimum-size)) minimum-size)))))
|
||||||
|
|
||||||
(defn dist [x1 y1 x2 y2]
|
(defn dist [x1 y1 x2 y2 & {:keys [y-sign x-sign]}]
|
||||||
(let [dx (- x1 x2)
|
(let [y-sign (or y-sign 1.0)
|
||||||
dy (- y1 y2)]
|
x-sign (or x-sign 1.0)
|
||||||
|
dx (* (- x1 x2) x-sign)
|
||||||
|
dy (* y-sign (- y1 y2))]
|
||||||
(Math/sqrt (+ (* dx dx) (* dy dy)))))
|
(Math/sqrt (+ (* dx dx) (* dy dy)))))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user