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

View File

@@ -11,6 +11,26 @@
[play-clj.utils :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]
{:run #(actions/respond entities %
@@ -97,10 +117,10 @@
(defn walk-to-blergh [entities]
(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/play-animation entities :blergh :appear :stop? false)
(actions/transition-music entities :fight))
(actions/transition-music entities nil)
(bloodclot-appear entities))
(defn pull-sword [entities]
(actions/play-animation entities :ego :reach)
@@ -122,23 +142,26 @@
(actions/add-entity entities :blergh (get-in @entities [:room :blergh]))
(actions/do-dialogue entities :ego "Who are you?!"
:bloodclot-head "I am Bloodclot, the Scottish goblin king!"
: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 "But I had never expected my liberator to be so..."
:bloodclot-head "Appetizing."
:bloodclot-head "I am Bloodclot, the Scottish goblin!"
:bloodclot-head "I've spent last 100 years training for this day."
:bloodclot-head "The day when I must best the worthiest of knights in battle."
: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.")
(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/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/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
:bloodclot-head "'Fight he must for one more test,\nHe will die if not the best.'"
:bloodclot-head "Ring any bells?"
:bloodclot-head "Your Georgia McGorgeous would be sorely disappointed to see such a cowardly hero now."
:bloodclot-head "Come, now. You're no hero. You're just a morsel."
:bloodclot-head "All this talking has worked up a fierce hunger. Come here, and I promise to make it quick."))
:bloodclot-head "Face it kiddo, you're no match for me, or my appetite."
:bloodclot-head "And Georgia McGorgeous would never go for such a cowardly knight anyhow."
:bloodclot-head "Let the feast begin."))
(defn try-to-pull-sword [entities missing-items obtained-items]
(let [item->proof {:trophy "wisdom" :medal "strength" :kiss "courage"}]

View File

@@ -24,6 +24,7 @@
"Pick up your weapon and fight!"]))) entities))
nil)
(defn start-swing-if-necessary [screen e]
(if (and (not= (:anim e) :swing)
(> (:x e) 190))
@@ -151,56 +152,60 @@
{}
:layers [(assoc (texture "space/background.png") :x 0 :y 0 :baseline 0)]
:timers {:taunt [10.0 8.0 taunt]}
:bloodclot-head (rooms/make-entity :bloodclot-head (assoc (animation->texture screen bloodclot-head-stand-anim)
:x 195 :y 138 :baseline 195
:anim bloodclot-head-stand-anim
:talk bloodclot-head-talk-anim
:keep-shoot bloodclot-head-keep-shoot-anim
:shoot bloodclot-head-shoot-anim
:anim-start 0
:stand bloodclot-head-stand-anim
:talk-color (color 0.95 0.4 0.2 1.0)))
:entities {:bloodclot-head (assoc (animation->texture screen bloodclot-head-stand-anim)
:x 195 :y 138 :baseline 195
:opacity 0.0
:anim bloodclot-head-stand-anim
:talk bloodclot-head-talk-anim
:keep-shoot bloodclot-head-keep-shoot-anim
:shoot bloodclot-head-shoot-anim
:anim-start 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)
:x 180 :y 50 :baseline 190
:stand blergh-stand-anim
: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!")
(sound! (sound "space/shock.ogg") :play)
(actions/play-animation entities :bloodclot-head :shoot :stop? false)
(actions/begin-animation entities :bloodclot-head :keep-shoot)
(actions/play-animation entities :ego :shock :stop? false)
(actions/begin-animation entities :bloodclot-head :stand)
(actions/play-animation entities :ego :burnt :stop? false)
(actions/play-animation entities :ego :passed-out :continue? true)
(common/go-to-jail entities)
#_(actions/do-dialogue entities :ego "Hey!"
:ego "What's going on? I was just about to teach Blergh a lesson!"))
:magic-slingshot (actions/get-script entities
(actions/do-dialogue entities
:ego "Hey Blergh!"
:ego "Take this!")
(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 {}
(sound! (sound "space/shock.ogg") :play)
(actions/play-animation entities :bloodclot-head :shoot :stop? false)
(actions/begin-animation entities :bloodclot-head :keep-shoot)
(actions/play-animation entities :ego :shock :stop? false)
(actions/begin-animation entities :bloodclot-head :stand)
(actions/play-animation entities :ego :burnt :stop? false)
(actions/play-animation entities :ego :passed-out :continue? true)
(actions/do-dialogue entities :bloodclot-head "Oh shucks. I overcooked him."
:bloodclot-head "No matter."
:bloodclot-head "Tomorrow, I will return with my legion of goblins."
:bloodclot-head "And THEN the feast will begin."
:bloodclot-head "Starting with his precious Georgia McGorgeous.")
(common/go-to-jail entities)
#_(actions/do-dialogue entities :ego "Hey!"
:ego "What's going on? I was just about to teach Blergh a lesson!"))
:magic-slingshot (actions/get-script entities
(actions/do-dialogue entities
:ego "Hey Blergh!"
:ego "Take this!")
(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
:bloodclot-head "Argh! My magic lightning helmet!"
:bloodclot-head "No matter. I will destroy you with my bare hands!"))})}
:bullet (assoc (animation->texture screen bullet)
:x 130 :y 85 :baseline 241
:walk bullet)
@@ -214,6 +219,10 @@
(if (get-in e [:state :broke-jewel?])
(assoc-in e [:room :entities :broken-jewel] (get-in e [:room :entities :broken-jewel]))
e)
(assoc-in e [:room :entities :blergh] (get-in e [:room :blergh]))
(assoc-in e [:room :entities :bloodclot-head] (get-in e [:room :bloodclot-head])))
))))
(if (get-in e [:state :seen-bloodclot?])
(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])))]
(play-key-sounds (get-in entities [:room :entities]))
(when-let [current-music (utils/get-current-music entities)]
(music! current-music :set-volume (get-in entities [:volume :value]) ))
(doseq [m (vals (get-in entities [:musics]))]
(when m
(music! m :set-volume (get-in entities [:volume :value]) )))
(label! (:fps entities) :set-text (str (game :fps)))
(render! screen (sort-by :baseline all-entities))