starting on a good sequence for blergh fight.

This commit is contained in:
2015-02-12 20:44:37 -08:00
parent 1ac64cfb2d
commit 30a5ffd91a
20 changed files with 132 additions and 10 deletions

View File

@@ -10,6 +10,7 @@
[play-clj.core :refer :all]
[play-clj.ui :refer :all]
[play-clj.utils :refer :all]
[play-clj.math :refer :all]
[play-clj.g2d :refer :all]))
(defn taunt [screen entities]
@@ -23,6 +24,88 @@
"Pick up your weapon and fight!"]))) entities))
nil)
(defn start-swing-if-necessary [screen e]
(if (and (not= (:anim e) :swing)
(> (:x e) 190))
(actions/start-animation screen e :swing)
e))
(defn start-fade-if-necessary [e screen]
(if (and (nil? (get-in e [:tweens :flash]))
(< (get-in e [:room :entities :ego :y]) 100))
(assoc-in e [:tweens :flash] (utils/tween :flash screen [:white-fade :opacity] 0.0 1.0 0.5 :power 3.0))
e))
(defn swing-at-blergh [entities]
(let [jump-path (bezier (map #(apply vector-2* %) [[15 45] [110 145] [195 180]]))
swing-path (bezier (map #(apply vector-2* %) [[195 180] [205 45]]))
jump-dist (utils/dist 15 45 205 45)
speed 190.0
jump-duration (/ jump-dist speed)
swing-dist (utils/dist 195 180 205 45)
swing-duration (/ swing-dist (* speed 1.5))]
(actions/run-action entities
(begin [this screen entities]
(-> entities
(update-in [:room :entities :ego]
#(actions/start-animation screen % :jump))
(assoc-in [:tweens :jump-pos] (utils/tween :jump-pos screen [:room :entities :ego :move-pct] 0.0 1.0 jump-duration :power 2))))
(continue [this screen entities]
(let [v (vector-2 0 0)
a (bezier! jump-path :value-at v (get-in entities [:room :entities :ego :move-pct] 0.0))]
(update-in entities [:room :entities :ego] #(assoc % :x (vector-2! v :x) :y (vector-2! v :y)))))
(done? [this screen entities]
(= (get-in entities [:room :entities :ego :move-pct]) 1.0))
(terminate [this screen entities]
(assoc-in entities [:room :entities :ego :move-pct] 0.0))
(can-skip? [this screen entities]
false))
(actions/run-action entities
(begin [this screen entities]
(-> entities
(update-in [:room :entities :ego]
#(actions/start-animation screen % :swing))
(assoc-in [:tweens :swing-pos] (utils/tween :swing-pos screen [:room :entities :ego :move-pct] 0.0 1.0 swing-duration :power 10))))
(continue [this screen entities]
(let [v (vector-2 0 0)
a (bezier! swing-path :value-at v (get-in entities [:room :entities :ego :move-pct] 0.0))]
(-> entities
(start-fade-if-necessary screen)
(update-in [:room :entities :ego] #(assoc % :x (vector-2! v :x) :y (vector-2! v :y))))))
(done? [this screen entities]
(= (get-in entities [:room :entities :ego :move-pct]) 1.0))
(terminate [this screen entities]
(-> entities
(assoc-in [:room :entities :ego :move-pct] 0.0)
(update-in [:room :entities :ego] #(actions/start-animation screen % :pant))))
(can-skip? [this screen entities]
false))
(actions/run-action entities
(begin [this screen entities]
(assoc-in entities [:tweens :flash] (utils/tween :flash screen [:white-fade :opacity] 1.0 0.0 3.0 :power 2.0)))
(continue [this screen entities]
entities)
(done? [this screen entities]
(nil? (get-in entities [:tweens :flash])))
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false))))
(defn make [screen]
(let [blergh-stand (texture "space/blergh-stand.png")
blergh-talk (texture "space/blergh-talk.png")
@@ -47,8 +130,9 @@
:talk-color (color 0.95 0.4 0.2 1.0)
: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/walk-straight-to entities :ego [205 45] :anim :jump :stop? false :speed 3.0)
(swing-at-blergh entities)
#_(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)
@@ -56,8 +140,8 @@
(actions/do-dialogue entities :ego "Ouch!"
:blergh "My turn.")
(common/go-to-jail entities)
(actions/do-dialogue entities :ego "Hey!"
#_(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