final blergh encounter.

This commit is contained in:
2014-12-19 12:31:16 -08:00
parent d097517c46
commit 5aee0724f5
4 changed files with 69 additions and 12 deletions

View File

@@ -1 +1 @@
{:active? true, :convinced-wizard? true, :inventory [:ladder :flask-1 :grass :medal :kiss :trophy ], :wizard-left? false, :clues #{}, :current-riddle :wool, :last-room :inside-castle, :wants-toy true, :mints-eaten 0, :object nil, :obtained-items #{:kiss :medal :flask-1 :grass :ladder :trophy}}
{:active? true, :convinced-wizard? true, :inventory [:ladder :flask-1 :grass :medal :kiss :trophy :flask-1-strength], :wizard-left? false, :clues #{}, :current-riddle :wool, :last-room :inside-castle, :wants-toy true, :mints-eaten 0, :object nil, :obtained-items #{:kiss :medal :flask-1 :grass :ladder :trophy}}

View File

@@ -110,7 +110,7 @@
(defn stop [screen entities target-id & {:keys [face]}]
(update-in entities [:room :entities target-id] (comp #(start-animation screen % :stand) (if face #(assoc % :facing face) identity))))
(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed]}]
(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir]}]
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
final-x (int final-x)
final-y (int final-y)
@@ -138,10 +138,10 @@
(update-in entities [:room :entities target-id]
#(start-animation screen
(assoc (jump-to screen entities % [(+ moved-x from-x) (+ moved-y from-y)] update-baseline?)
:facing (cond (< delta-x 0) :left
(> delta-x 0) :right
:else (:facing %)))
:walk
:facing (or override-dir (cond (< delta-x 0) :left
(> delta-x 0) :right
:else (:facing %))))
(or anim :walk)
))))))
(done? [this screen entities]
@@ -455,6 +455,8 @@
music-changed? (not= old-music new-music)]
(run-action entities
(begin [this screen entities]
(doseq [[k] (get-in entities [:room :timers])]
(remove-timer! screen k))
(-> entities
(assoc-in [:transition]
(assoc (texture "black.png")
@@ -508,6 +510,8 @@
(<= (get-in entities [:transition :opacity]) 0.0))
(terminate [this screen entities]
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
(add-timer! screen k start time))
(dissoc entities :transition))
(can-skip? [this screen entities]

View File

@@ -11,19 +11,44 @@
[play-clj.utils :refer :all]
[play-clj.g2d :refer :all]))
(defn taunt [screen entities]
(when (and (not (get-in entities [:actions :script-running?]))
(get-in entities [:state :active?]))
((actions/get-script entities (actions/do-dialogue entities :blergh (rand-nth ["Come on, little man! Try and hit me!"
"What's the matter? Cold feet?"
"Come here and fight me like man!"
"Your precious Georgia McGorgeous would be laughing if she saw you now."
"Pick up your weapon and fight!"]))) entities))
nil)
(defn make [screen]
(let [blergh-stand (texture "space/blergh-stand.png")
blergh-talk (texture "space/blergh-talk.png")
blergh-flex (texture "space/blergh-flex.png")
blergh-talk-anim (animation 0.3 [blergh-talk blergh-stand])
blergh-stand-anim (animation 0.7 [blergh-flex blergh-stand])
]
blergh-swing (utils/make-anim "space/blergh-swing.png" [106 165] 0.1 [0 0 1 2 3 4 ])]
(rooms/make :music :town-1
:interactions
{}
:layers [(assoc (texture "space/background.png") :x 0 :y 0 :baseline 0)]
:timers {:taunt [10.0 8.0 taunt]}
:entities {:blergh (assoc (animation->texture screen blergh-stand-anim) :x 180 :y 50 :baseline 190 :anim blergh-stand-anim :anim-start 0 :stand blergh-stand-anim :talk blergh-talk-anim)}
:entities {:blergh (assoc (animation->texture screen blergh-stand-anim)
:x 180 :y 50 :baseline 190
:anim blergh-stand-anim :anim-start 0
:stand blergh-stand-anim :talk blergh-talk-anim
:swing blergh-swing
:script (actions/get-script entities (actions/do-dialogue entities :blergh "Come on! Try and hit me!"))
:scripts {:sword (actions/get-script entities
(actions/walk-straight-to entities :ego [205 45])
(actions/play-animation entities :ego :swing)
(actions/do-dialogue entities :blergh "Ha ha ha! Is that the best you can do?"
:blergh "Take this!")
(actions/play-animation entities :blergh :swing)
(actions/walk-straight-to entities :ego [100 45] :anim :squat :override-dir :right :speed 3.0)
(actions/do-dialogue entities :ego "Ouch!"
:blergh "Why don't you try that again?"))})}
:collision "space/collision.png"
:scale-fn (constantly 1.5)
:start-pos [43 80])))

View File

@@ -85,6 +85,23 @@
((:get-script default-interaction) (get-in entities [:cursor :current]) [x y])) entities))
entities))))
(defn drink-blergh [entities]
(actions/walk-straight-to entities :ego [205 45])
(sound! (sound "ego/potion.ogg") :play)
(actions/play-animation entities :ego :grow :stop? false)
(actions/do-dialogue entities
:blergh "What this? A potion of strength?"
:blergh "You're still no match for me."
:blergh "Give it to me, or I'll make you regret it!")
(actions/present-choices entities {:choices ["Ok."
{:run #(do (actions/respond entities % :ego "Here you go."))}
"No way!"
{:run #(do (actions/respond entities % :blergh "Then take this!")
(actions/play-animation entities :blergh :swing)
(actions/walk-straight-to entities :ego [100 45] :anim :squat :override-dir :right :speed 3.0)
(actions/do-dialogue entities :ego "Yeow!!"
:ego "Even with that potion, I'm not strong enough."))}]}))
(defn get-ego [screen start-pos start-scale]
(let [player-sheet (texture! (texture "player.png") :split 18 36)
@@ -124,6 +141,7 @@
grow (animation 0.1 (for [i [0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 3 0 0 0 0 3 0 0 0 3 3 0 0 0 2 2 0 0 2 0 0 2 0 2 0 2 0 2 0 2 0 2 3 2 3 2 3 2 3 2 4 3 4 3 4 3 4]]
(texture (aget grow-sheet 0 i))))
hold-up-to-window (utils/make-anim "ego/hold-up-to-window.png" [18 36] 0.1 [0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 1 0 0 0 0 0 0])
swing (utils/make-anim "ego/swing.png" [36 36] 0.05 (flatten [[0 0 0 1 2 3 3 3 3 ]]))
get-sick (animation 0.3 (map (partial get [(aget talk-sheet 0 0 ) (texture "ego/get-sick.png")]) [0 1 1 1 1 1 1 1 1 1 1 1]) )
ego {:right {:walk walk-right
:stand stand-anim
@@ -138,6 +156,7 @@
:grow grow
:get-sick get-sick
:hold-up-to-window hold-up-to-window
:swing swing
[:fire 1] fire-1-anim
[:fire 2] fire-2-anim
[:fire 3] fire-3-anim}
@@ -179,9 +198,12 @@
(condp = (:value cursor)
:flask-1-with-cream-of-mushroom (actions/get-script entities (actions/talk entities :ego "Blegh! Gross!"))
:flask-1-strength (actions/get-script entities
(actions/talk entities :ego "I'll just take a sip!")
(sound! (sound "ego/potion.ogg") :play)
(actions/play-animation entities :ego :grow :stop? false))
(if (get-in @entities [:room :entities :blergh])
(drink-blergh entities)
(do
(actions/talk entities :ego "I'll just take a sip!")
(sound! (sound "ego/potion.ogg") :play)
(actions/play-animation entities :ego :grow :stop? false))))
:recipe (actions/get-script entities (actions/do-dialogue entities
:ego "The recipe says:"
:ego "'For strength beyond measure,\nyou must mix, at your leisure:'"
@@ -250,6 +272,10 @@
:clues #{}
:mints-eaten 0}))
(defscreen scene
:on-timer
(fn [screen [entities]]
((get-in entities [:room :timers (:id screen) 2]) screen entities))
:on-show
(fn [screen entities]
(let [screen (assoc screen :total-time 0)]
@@ -290,7 +316,9 @@
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)}]
(play-sound (get-in entities [:musics (get-in entities [:room :music])]))
(doseq [[k [start time fn]] (get-in entities [:room :timers])]
(add-timer! screen k start time))
(if-let [apply-state (get-in entities [:room :apply-state])]
(apply-state entities)
entities))))