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

@@ -116,7 +116,7 @@
(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 anim override-dir]}]
(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir stop?]}]
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
final-x (int final-x)
final-y (int final-y)
@@ -155,7 +155,9 @@
(< (utils/dist final-x final-y from-x from-y) 1)))
(terminate [this screen entities]
(stop screen entities target-id :face face))
(if (or (nil? stop?) stop?)
(stop screen entities target-id :face face)
entities))
(can-skip? [this screen entities]
false))))

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

View File

@@ -176,12 +176,14 @@
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 ]]))
jump (utils/make-anim "ego/swing.png" [36 75] 0.2 (flatten [[1 2]]))
swing (utils/make-anim "ego/swing.png" [36 75] 0.145 (flatten [[3 4 5 6 7 ]]))
grow-talk (utils/make-anim "ego/grow-talk.png" [18 36] 0.2 (range 2))
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]) )
spear (utils/make-anim "ego/spear.png" [18 100] 0.2 [0 1 2 3 2 3 2 3 2 3 2 1 0])
crowbar (utils/make-anim "ego/crowbar.png" [36 36] 0.1 [0 0 0 1 1 2 2 2 2 2 3 2 3 2 3 2 3 2 3 3 3 1 1 0 0 0])
shoot (utils/make-anim "ego/shoot.png" [24 36] 0.075 [0 0 0 1 1 2 2 2 2 2 2 2 2 3 4 5 4])
pant (utils/make-anim "ego/pant.png" [31 36] 0.5 [0 1])
ego {:right {:walk walk-right
:stand stand-anim
@@ -202,12 +204,14 @@
:reach-up reach-up
:reach-down reach-down
:reach-start reach-start
:jump jump
:reach-stop reach-stop
:shoot shoot
[:fire 1] fire-1-anim
[:fire 2] fire-2-anim
[:fire 3] fire-3-anim
:spear spear}
:spear spear
:pant pant}
:left {:walk (utils/flip walk-right)
:stand (utils/flip stand-anim)
:talk (utils/flip talk-anim)
@@ -230,7 +234,8 @@
[:fire 1] (utils/flip fire-1-anim)
[:fire 2] (utils/flip fire-2-anim)
[:fire 3] (utils/flip fire-3-anim)
:spear (utils/flip spear)}
:spear (utils/flip spear)
:pant (utils/flip pant)}
:baseline (- 240 (last start-pos))
:facing :right
:origin-x 9
@@ -402,7 +407,11 @@
:scale-y 20
:baseline 9500
:opacity 0.0)
:white-fade (assoc (texture "white.png")
:scale-x 20
:scale-y 20
:baseline 9500
:opacity 0.0)
:actions {:object nil
:channel (chan)
:current nil