adding camera panning. nice.

This commit is contained in:
2015-02-19 11:24:32 -08:00
parent dfdfcd7914
commit e517fffbd4
6 changed files with 179 additions and 116 deletions

View File

@@ -4,6 +4,7 @@
[advent.actions :as actions]
[advent.screens.items :as items]
[advent.utils :as utils]
[advent.tween :as tween]
[clojure.zip :as zip]
[clojure.set :as set]
[clojure.string :as str]
@@ -16,7 +17,8 @@
(defn taunt [screen entities]
(when (and (not (get-in entities [:actions :script-running?]))
(get-in entities [:state :active?])
(not (get-in entities [:state :blergh-dead?])))
(not (get-in entities [:state :blergh-dead?]))
(not (actions/has-item? entities :magic-slingshot)))
((actions/get-script entities (actions/do-dialogue entities :bloodclot-head (rand-nth ["Come on, little man! Try and hit me!"
"What's the matter? Cold feet?"
"Come here and fight me like man!"
@@ -24,6 +26,18 @@
"Pick up your weapon and fight!"]))) entities))
nil)
(defn shock [screen entities]
(when (and (not (get-in entities [:actions :script-running?]))
(get-in entities [:state :active?])
(not (get-in entities [:state :blergh-dead?]))
(actions/has-item? entities :magic-slingshot))
((actions/get-script 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/do-dialogue entities :bloodclot-head "Dang! Come a little closer!"))
entities))
nil)
(defn start-swing-if-necessary [screen e]
(if (and (not= (:anim e) :swing)
@@ -34,7 +48,7 @@
(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))
(assoc-in e [:tweens :flash] (tween/tween :flash screen [:white-fade :opacity] 0.0 1.0 0.5 :ease tween/ease-in-cubic))
e))
(defn bloodclot-disappear [entities]
@@ -45,9 +59,9 @@
(sound! (sound "inside-house/disappear.ogg") :play)
(-> entities
(assoc-in [:tweens :bloodclot-head-appear]
(utils/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 1.0 0.0 1.0 :power 4.0))
(tween/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic))
(assoc-in [:tweens :bloodclot-appear]
(utils/tween :bloodclot-appear screen [:room :entities :bloodclot :opacity] 1.0 0.0 1.0 :power 4.0))))
(tween/tween :bloodclot-appear screen [:room :entities :bloodclot :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic))))
(continue [this screen entities]
entities)
@@ -82,25 +96,25 @@
:scale-y 0.5
:opacity 0.5
:baseline 240))
(assoc-in [:tweens :cloud-up] (utils/tween :cloud-up screen [:room :entities :cloud :y]
(assoc-in [:tweens :cloud-up] (tween/tween :cloud-up screen [:room :entities :cloud :y]
(get-in entities [:room :entities :ego :y])
(+ (get-in entities [:room :entities :ego :y]) 20)
1.0))
(assoc-in [:tweens :cloud-fade] (utils/tween :cloud-fade screen [:room :entities :cloud :opacity]
(assoc-in [:tweens :cloud-fade] (tween/tween :cloud-fade screen [:room :entities :cloud :opacity]
0.5
0.0
1.0))
(assoc-in [:tweens :cloud-grow] (utils/tween :cloud-grow screen [:room :entities :cloud :scale-y]
(assoc-in [:tweens :cloud-grow] (tween/tween :cloud-grow screen [:room :entities :cloud :scale-y]
0.5
2.5
1.0))
(assoc-in [:tweens :cloud-grow-2] (utils/tween :cloud-grow-2 screen [:room :entities :cloud :scale-x]
(assoc-in [:tweens :cloud-grow-2] (tween/tween :cloud-grow-2 screen [:room :entities :cloud :scale-x]
0.5
2.5
1.0))
(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))))
(assoc-in [:tweens :jump-pos] (tween/tween :jump-pos screen [:room :entities :ego :move-pct] 0.0 1.0 jump-duration :ease tween/ease-in-quadratic))))
(continue [this screen entities]
(let [v (vector-2 0 0)
@@ -122,7 +136,7 @@
(-> 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))))
(assoc-in [:tweens :swing-pos] (tween/tween :swing-pos screen [:room :entities :ego :move-pct] 0.0 1.0 swing-duration :ease tween/ease-in-dectic))))
(continue [this screen entities]
(let [v (vector-2 0 0)
@@ -143,7 +157,7 @@
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)))
(assoc-in entities [:tweens :flash] (tween/tween :flash screen [:white-fade :opacity] 1.0 0.0 3.0 :ease tween/ease-in-quadratic)))
(continue [this screen entities]
entities)
@@ -172,7 +186,8 @@
:interactions
{}
: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]
:shock [5.0 1.0 shock]}
:entities {:appear (assoc effect
:x 240 :y 50
:baseline 200)