camera shake.

This commit is contained in:
Bryce Covert
2015-10-10 18:14:54 -07:00
parent 86f5b3484f
commit 4d154ce47f
3 changed files with 38 additions and 1 deletions

View File

@@ -880,3 +880,35 @@
(fade-out-georgia entities)
(do-stop entities :georgia-face)
(transition-music entities nil :duration 1.0))))
(defn do-pan [entities x y scale-fn & [ease duration]]
(actions/run-action entities
(begin [this screen entities]
(pan-to screen entities x y scale-fn ease duration))
(continue [this screen entities]
entities)
(done? [this screen entities]
(nil? (get-in entities [:tweens :cam-y])))
(terminate [this screen entities]
entities)
(skip-type [this screen entities]
:none)))
(defn camera-shake [entities length]
(dotimes [n length]
(actions/do-pan entities (get-in @entities [:cam :x])
(+ (get-in @entities [:cam :y])
5)
(constantly (get-in @entities [:cam :zoom]))
nil
(* 0.01 (inc n)))
(actions/do-pan entities (get-in @entities [:cam :x])
(- (get-in @entities [:cam :y])
5)
(constantly (get-in @entities [:cam :zoom]))
nil
(* 0.01 (inc n)))))