safe opening sound.

This commit is contained in:
2014-11-10 16:55:07 -08:00
parent 8e87c39d0e
commit 04bd21c85d
3 changed files with 41 additions and 12 deletions

View File

@@ -110,7 +110,7 @@
(can-skip? [this screen entities]
false))))
(defn play-animation [entities target-id anim]
(defn play-animation [entities target-id anim & {:keys [stop?]}]
(run-action entities
(begin [this screen entities]
(update-in entities [:room :entities target-id] #(start-animation screen % anim) ))
@@ -123,7 +123,9 @@
(- (:total-time screen) (get-in entities [:room :entities target-id :anim-start]))))
(terminate [this screen entities]
(stop screen entities target-id))
(if (or (nil? stop?) stop?)
(stop screen entities target-id)
(assoc-in entities [:room :entities target-id :anim] nil)))
(can-skip? [this screen entities]
false)))
@@ -196,9 +198,10 @@
(defn get-text-duration [text]
(* (count (s/split text #" ")) 0.5))
(defn talk [entities target-id text & {:keys [stop?]}]
(defn talk [entities target-id text & {:keys [stop? animate?]}]
(let [initial-time (atom nil)
stop? (if (nil? stop?) true stop?)]
stop? (if (nil? stop?) true stop?)
animate? (if (nil? animate?) true animate?)]
(run-action entities
(begin [this screen entities]
(let [_ (swap! initial-time #(or % (:total-time screen)))
@@ -211,7 +214,9 @@
:x (get-in entities [:room :entities target-id :x]) :y (+ (get-in entities [:room :entities target-id :y]) height)
:target-id target-id
:scale scale)
(update-in entities [:room :entities target-id ] #(start-animation screen % :talk))))
(if animate?
(update-in entities [:room :entities target-id ] #(start-animation screen % :talk))
entities)))
(continue [this screen entities] entities)
@@ -303,6 +308,23 @@
(can-skip? [this screen entities]
false)))
(defn play-sound [entities sound-file]
(let [m (music sound-file)]
(run-action entities
(begin [this screen entities]
(music! m :play)
entities)
(continue [this screen entities] entities)
(done? [this screen entities]
(not (music! m :is-playing)))
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false))))
(defn give [entities item]
(run-action entities
(begin [this screen entities]

View File

@@ -55,13 +55,12 @@
:script (actions/get-script entities
(if (get-in @entities [:state :opened-crack?])
(do (actions/walk-to entities :ego [70 80])
(actions/play-animation entities :ego :squat)
(actions/talk entities :ego "I can see Gandarf, the wizard inside.")
(actions/play-animation entities :ego :squat)
(actions/talk entities :ego "It looks like he's opening his Magi-safe.")
(actions/play-animation entities :ego :squat)
(actions/talk entities :ego "[todo: sounds play.]")
(actions/play-animation entities :ego :squat)
(actions/play-animation entities :ego :start-squat :stop? false)
(actions/talk entities :ego "I can see Gandarf, the wizard inside." :animate? false :stop? false)
(actions/talk entities :ego "It looks like he's opening his Magi-safe." :animate? false :stop? false)
(actions/play-sound entities "safe-sound.ogg")
(actions/talk entities :ego "So that's the code to his safe..." :animate? false :stop? false)
(actions/play-animation entities :ego :end-squat)
(actions/talk entities :ego "A lot of good it'll do me to know his password while he's still there."))
(do (actions/walk-to entities :ego [80 80])
(actions/talk entities :ego "It looks like the wall is crumbling here.")

View File

@@ -91,6 +91,10 @@
(texture (aget stand-sheet 0 i))))
talk-anim (animation 0.2 (for [i (range 8)]
(texture (aget talk-sheet 0 i))))
start-squat (animation 0.05 (for [i [0 1 2 3]]
(texture (aget squat-sheet 0 i))))
end-squat (animation 0.05 (for [i [3 2 1 0]]
(texture (aget squat-sheet 0 i))))
squat-anim (animation 0.05 (for [i [0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 2 1] ]
(texture (aget squat-sheet 0 i))))
reach-anim (animation 0.1 (for [i [0 1 2 3 3 3 3 3 3 2 1 0]]
@@ -107,6 +111,8 @@
:stand stand-anim
:talk talk-anim
:squat squat-anim
:start-squat start-squat
:end-squat end-squat
:reach reach-anim
:cat-toy cat-toy-anim
[:fire 1] fire-1-anim
@@ -115,6 +121,8 @@
:left {:walk (utils/flip walk-right)
:stand (utils/flip stand-anim)
:talk (utils/flip talk-anim)
:start-squat (utils/flip start-squat)
:end-squat (utils/flip end-squat)
:squat (utils/flip squat-anim)
:reach (utils/flip reach-anim)
:cat-toy (utils/flip cat-toy-anim)