reworked dialogue

This commit is contained in:
2015-02-18 08:29:52 -08:00
parent 352bfb9238
commit c7591dd3f2
4 changed files with 107 additions and 71 deletions

View File

@@ -482,7 +482,9 @@
(nil? (get-in entities [:tweens :fade-out-music]))) (nil? (get-in entities [:tweens :fade-out-music])))
(terminate [this screen entities] (terminate [this screen entities]
(music! (utils/get-current-music entities) :stop) (doseq [m (-> entities :musics vals)
:when m]
(music! m :stop))
(let [entities (-> entities (let [entities (-> entities
(assoc-in [:music-override :value] new-music) (assoc-in [:music-override :value] new-music)
(assoc-in [:volume :value] 1.0))] (assoc-in [:volume :value] 1.0))]
@@ -494,10 +496,11 @@
false)))) false))))
(defn transition-background [entities new-background [x y]] (defn transition-background [entities new-background [x y] & {:keys [transition-music?]}]
(let [old-music (get-music (get-in @entities [:room :music]) (get-in @entities [:state :time])) (let [transition-music? (if (nil? transition-music?) true transition-music?)
old-music (get-music (get-in @entities [:room :music]) (get-in @entities [:state :time]))
new-music (get-music (get-in @entities [:rooms new-background :music]) (get-in @entities [:state :time])) new-music (get-music (get-in @entities [:rooms new-background :music]) (get-in @entities [:state :time]))
music-changed? (not= old-music new-music)] music-changed? (and transition-music? (not= old-music new-music))]
(run-action entities (run-action entities
(begin [this screen entities] (begin [this screen entities]
(doseq [[k] (get-in entities [:room :timers])] (doseq [[k] (get-in entities [:room :timers])]
@@ -543,11 +546,11 @@
(apply-state entities) (apply-state entities)
entities) entities)
entities (utils/update-override entities)] entities (utils/update-override entities)]
(when (not= new-music old-music) (when (and (not= new-music old-music) transition-music?)
(doseq [[k v] (:musics entities) (doseq [[k v] (:musics entities)
:when (and v (not= new-music k))] :when (and v (not= new-music k))]
(music! v :stop)) (music! v :stop))
(when new-music (when (and new-music transition-music?)
(music! (get-in entities [:musics new-music]) :set-volume 0) (music! (get-in entities [:musics new-music]) :set-volume 0)
(music! (get-in entities [:musics new-music]) :play))) (music! (get-in entities [:musics new-music]) :play)))
(-> entities (-> entities

View File

@@ -11,6 +11,26 @@
[play-clj.utils :refer :all] [play-clj.utils :refer :all]
[play-clj.g2d :refer :all])) [play-clj.g2d :refer :all]))
(defn bloodclot-appear [entities]
(actions/run-action entities
(begin [this screen entities]
(-> entities
(assoc-in [:tweens :bloodclot-head-appear]
(utils/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 0.0 1.0 0.2 :power 4.0))
(assoc-in [:tweens :bloodclot-appear]
(utils/tween :bloodclot-appear screen [:room :entities :bloodclot :opacity] 0.0 1.0 0.2 :power 4.0))))
(continue [this screen entities]
entities)
(done? [this screen entities]
(= 1.0 (get-in entities [:room :entities :bloodclot :opacity])))
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(defn nice-trophy-dialogue [entities] (defn nice-trophy-dialogue [entities]
{:run #(actions/respond entities % {:run #(actions/respond entities %
@@ -97,10 +117,10 @@
(defn walk-to-blergh [entities] (defn walk-to-blergh [entities]
(actions/walk-to entities :ego [85 145] :face :right) (actions/walk-to entities :ego [85 145] :face :right)
(actions/transition-background entities :space [0 65]) (actions/transition-background entities :space [0 65] :transition-music? false)
(actions/walk-straight-to entities :ego [160 45] :face :right) (actions/walk-straight-to entities :ego [160 45] :face :right)
(actions/play-animation entities :blergh :appear :stop? false) (actions/transition-music entities nil)
(actions/transition-music entities :fight)) (bloodclot-appear entities))
(defn pull-sword [entities] (defn pull-sword [entities]
(actions/play-animation entities :ego :reach) (actions/play-animation entities :ego :reach)
@@ -122,23 +142,26 @@
(actions/add-entity entities :blergh (get-in @entities [:room :blergh])) (actions/add-entity entities :blergh (get-in @entities [:room :blergh]))
(actions/do-dialogue entities :ego "Who are you?!" (actions/do-dialogue entities :ego "Who are you?!"
:bloodclot-head "I am Bloodclot, the Scottish goblin king!" :bloodclot-head "I am Bloodclot, the Scottish goblin!"
:bloodclot-head "I have waited patiently for the last 100 years for someone to\npull the sword and return me to my throne!" :bloodclot-head "I've spent last 100 years training for this day."
:bloodclot-head "But I had never expected my liberator to be so..." :bloodclot-head "The day when I must best the worthiest of knights in battle."
:bloodclot-head "Appetizing." :bloodclot-head "But I had never expected my foe to be so..."
:bloodclot-head "... appetizing."
:bloodclot-head "You're no hero. You're just a morsel."
:bloodclot-head "Come here, and I promise I will spare you much pain."
:ego "Wait a second. I'm just a kid.") :ego "Wait a second. I'm just a kid.")
(actions/walk-straight-to entities :ego [115 45] :override-dir :right) (actions/walk-straight-to entities :ego [115 45] :override-dir :right)
(actions/do-dialogue entities :ego "I'm just trying to impress Georgia McGorgeous.") (actions/do-dialogue entities :ego "I'm just trying to impress Georgia McGorgeous.")
(actions/walk-straight-to entities :ego [100 45] :override-dir :right) (actions/walk-straight-to entities :ego [75 45] :override-dir :right)
(actions/do-dialogue entities :ego "I just... accidentally pulled the sword!") (actions/do-dialogue entities :ego "I just... accidentally pulled the sword!")
(actions/walk-straight-to entities :ego [35 45] :override-dir :right) (actions/walk-straight-to entities :ego [35 45] :override-dir :right)
(actions/do-dialogue entities :ego "I wouldn't taste very good anyhow!") (actions/do-dialogue entities :ego "I wouldn't taste very good anyhow!")
(actions/do-dialogue entities (actions/do-dialogue entities
:bloodclot-head "'Fight he must for one more test,\nHe will die if not the best.'" :bloodclot-head "'Fight he must for one more test,\nHe will die if not the best.'"
:bloodclot-head "Ring any bells?" :bloodclot-head "Ring any bells?"
:bloodclot-head "Your Georgia McGorgeous would be sorely disappointed to see such a cowardly hero now." :bloodclot-head "Face it kiddo, you're no match for me, or my appetite."
:bloodclot-head "Come, now. You're no hero. You're just a morsel." :bloodclot-head "And Georgia McGorgeous would never go for such a cowardly knight anyhow."
:bloodclot-head "All this talking has worked up a fierce hunger. Come here, and I promise to make it quick.")) :bloodclot-head "Let the feast begin."))
(defn try-to-pull-sword [entities missing-items obtained-items] (defn try-to-pull-sword [entities missing-items obtained-items]
(let [item->proof {:trophy "wisdom" :medal "strength" :kiss "courage"}] (let [item->proof {:trophy "wisdom" :medal "strength" :kiss "courage"}]

View File

@@ -24,6 +24,7 @@
"Pick up your weapon and fight!"]))) entities)) "Pick up your weapon and fight!"]))) entities))
nil) nil)
(defn start-swing-if-necessary [screen e] (defn start-swing-if-necessary [screen e]
(if (and (not= (:anim e) :swing) (if (and (not= (:anim e) :swing)
(> (:x e) 190)) (> (:x e) 190))
@@ -151,56 +152,60 @@
{} {}
:layers [(assoc (texture "space/background.png") :x 0 :y 0 :baseline 0)] :layers [(assoc (texture "space/background.png") :x 0 :y 0 :baseline 0)]
:timers {:taunt [10.0 8.0 taunt]} :timers {:taunt [10.0 8.0 taunt]}
:bloodclot-head (rooms/make-entity :bloodclot-head (assoc (animation->texture screen bloodclot-head-stand-anim) :entities {:bloodclot-head (assoc (animation->texture screen bloodclot-head-stand-anim)
:x 195 :y 138 :baseline 195 :x 195 :y 138 :baseline 195
:anim bloodclot-head-stand-anim :opacity 0.0
:talk bloodclot-head-talk-anim :anim bloodclot-head-stand-anim
:keep-shoot bloodclot-head-keep-shoot-anim :talk bloodclot-head-talk-anim
:shoot bloodclot-head-shoot-anim :keep-shoot bloodclot-head-keep-shoot-anim
:anim-start 0 :shoot bloodclot-head-shoot-anim
:stand bloodclot-head-stand-anim :anim-start 0
:talk-color (color 0.95 0.4 0.2 1.0))) :stand bloodclot-head-stand-anim
:talk-color (color 0.95 0.4 0.2 1.0))
:bloodclot (assoc (animation->texture screen blergh-stand-anim)
:x 180 :y 50 :baseline 190
:stand blergh-stand-anim
:opacity 0.0
:appear blergh-appear
:grow blergh-grow
:script (actions/get-script entities (actions/do-dialogue entities :bloodclot-head "Come on! Try and hit me!"))
:scripts {:sword (actions/get-script entities
(swing-at-blergh entities)
(actions/do-dialogue entities :bloodclot-head "Ha ha ha! Is that the best you can do?"
:bloodclot-head "Take this!")
:blergh (rooms/make-entity :blergh (assoc (animation->texture screen blergh-stand-anim) (sound! (sound "space/shock.ogg") :play)
:x 180 :y 50 :baseline 190 (actions/play-animation entities :bloodclot-head :shoot :stop? false)
:stand blergh-stand-anim (actions/begin-animation entities :bloodclot-head :keep-shoot)
(actions/play-animation entities :ego :shock :stop? false)
:appear blergh-appear (actions/begin-animation entities :bloodclot-head :stand)
:grow blergh-grow (actions/play-animation entities :ego :burnt :stop? false)
(actions/play-animation entities :ego :passed-out :continue? true)
:script (actions/get-script entities (actions/do-dialogue entities :bloodclot-head "Come on! Try and hit me!")) (actions/do-dialogue entities :bloodclot-head "Oh shucks. I overcooked him."
:scripts {:sword (actions/get-script entities :bloodclot-head "No matter."
(swing-at-blergh entities) :bloodclot-head "Tomorrow, I will return with my legion of goblins."
:bloodclot-head "And THEN the feast will begin."
(actions/do-dialogue entities :bloodclot-head "Ha ha ha! Is that the best you can do?" :bloodclot-head "Starting with his precious Georgia McGorgeous.")
:bloodclot-head "Take this!") (common/go-to-jail entities)
#_(actions/do-dialogue entities :ego "Hey!"
(sound! (sound "space/shock.ogg") :play) :ego "What's going on? I was just about to teach Blergh a lesson!"))
(actions/play-animation entities :bloodclot-head :shoot :stop? false) :magic-slingshot (actions/get-script entities
(actions/begin-animation entities :bloodclot-head :keep-shoot) (actions/do-dialogue entities
(actions/play-animation entities :ego :shock :stop? false) :ego "Hey Blergh!"
(actions/begin-animation entities :bloodclot-head :stand) :ego "Take this!")
(actions/play-animation entities :ego :burnt :stop? false) (actions/play-animation entities :ego :shoot)
(actions/play-animation entities :ego :passed-out :continue? true) (actions/add-entity entities :bullet (get-in @entities [:room :bullet]))
(actions/walk-straight-to entities :bullet [213 166] :update-baseline? false :speed 5.0)
(common/go-to-jail entities) (actions/add-entity entities :broken-jewel (get-in @entities [:room :broken-jewel]))
#_(actions/do-dialogue entities :ego "Hey!" (Thread/sleep 500)
:ego "What's going on? I was just about to teach Blergh a lesson!")) (actions/remove-entity entities :bullet)
:magic-slingshot (actions/get-script entities (actions/update-state entities #(assoc % :broke-jewel? true))
(actions/do-dialogue entities (actions/do-dialogue entities
:ego "Hey Blergh!" :bloodclot-head "Argh! My magic lightning helmet!"
:ego "Take this!") :bloodclot-head "No matter. I will destroy you with my bare hands!"))})}
(actions/play-animation entities :ego :shoot)
(actions/add-entity entities :bullet (get-in @entities [:room :bullet]))
(actions/walk-straight-to entities :bullet [213 166] :update-baseline? false :speed 5.0)
(actions/add-entity entities :broken-jewel (get-in @entities [:room :broken-jewel]))
(Thread/sleep 500)
(actions/remove-entity entities :bullet)
(actions/update-state entities #(assoc % :broke-jewel? true))
(actions/do-dialogue entities
:blergh "Argh! My magic lightning helmet!"
:blergh "No matter. I will destroy you with my bare hands!"))}))
:entities {}
:bullet (assoc (animation->texture screen bullet) :bullet (assoc (animation->texture screen bullet)
:x 130 :y 85 :baseline 241 :x 130 :y 85 :baseline 241
:walk bullet) :walk bullet)
@@ -214,6 +219,10 @@
(if (get-in e [:state :broke-jewel?]) (if (get-in e [:state :broke-jewel?])
(assoc-in e [:room :entities :broken-jewel] (get-in e [:room :entities :broken-jewel])) (assoc-in e [:room :entities :broken-jewel] (get-in e [:room :entities :broken-jewel]))
e) e)
(assoc-in e [:room :entities :blergh] (get-in e [:room :blergh])) (if (get-in e [:state :seen-bloodclot?])
(assoc-in e [:room :entities :bloodclot-head] (get-in e [:room :bloodclot-head]))) (assoc-in e [:room :entities :bloodclot :opacity ] 1.0)
)))) e)
(if (get-in e [:state :seen-bloodclot?])
(assoc-in e [:room :entities :bloodclot-head :opacity ] 1.0)
e)
(assoc-in e [:state :seen-bloodclot?] true))))))

View File

@@ -483,8 +483,9 @@
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))] all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
(play-key-sounds (get-in entities [:room :entities])) (play-key-sounds (get-in entities [:room :entities]))
(when-let [current-music (utils/get-current-music entities)] (doseq [m (vals (get-in entities [:musics]))]
(music! current-music :set-volume (get-in entities [:volume :value]) )) (when m
(music! m :set-volume (get-in entities [:volume :value]) )))
(label! (:fps entities) :set-text (str (game :fps))) (label! (:fps entities) :set-text (str (game :fps)))
(render! screen (sort-by :baseline all-entities)) (render! screen (sort-by :baseline all-entities))