battle pacing works.

This commit is contained in:
Bryce Covert
2018-01-11 22:51:25 -08:00
parent 3ac732b172
commit dc35617281
15 changed files with 167 additions and 91 deletions

View File

@@ -29,8 +29,9 @@
[146 185])]
(-> entities
(update-in [:room :entities :heart] #(assoc % :opacity 1 :x x :y y))
(assoc-in [:tweens :heart-y] (tween/tween :heart-y screen [:room :entities :heart :y] y (+ y 10) 0.5 :ease tween/ease-out-cubic))
(assoc-in [:tweens :heart-opacity] (tween/tween :heart-opacity screen [:room :entities :heart :opacity] 1.0 0.0 0.5 :ease tween/ease-in-cubic))
(update-in [:room :entities :heart] #(actions/start-animation screen % :beat))
(assoc-in [:tweens :heart-y] (tween/tween :heart-y screen [:room :entities :heart :y] y (+ y 10) 1.0 :ease tween/ease-out-cubic))
(assoc-in [:tweens :heart-opacity] (tween/tween :heart-opacity screen [:room :entities :heart :opacity] 1.0 0.0 3.0 :ease tween/ease-in-out-quadratic))
(cause-damage is-player-wound?))))
(defn stop-swing-if-necessary [screen {{{{:keys [anim anim-start] {:keys [tongue-swing]} :left } :ego} :entities} :room :as entities}]
@@ -41,13 +42,20 @@
(update-in entities [:room :entities :ego] #(actions/start-animation screen % :tongue-idle))
entities))
(defn trigger-tongue [screen {{{
{:keys [state started anim anim-start]} :tongue
{ego-anim :anim {ego-windup :tongue-windup} :left } :ego
(defn trigger-tongue [screen {{{{:keys [state started anim anim-start]} :tongue
{ego-anim :anim ego-anim-start :anim-start {ego-windup :tongue-windup} :left } :ego
} :entities
:keys [ego-hearts tongue-hearts]} :room
:as entities}]
(let [time-in-state (- (:total-time screen) (or started (:total-time screen)))
tongue-finished? (animation! anim
:is-animation-finished
(- (:total-time screen) anim-start))
ego-finished? (animation! ego-anim
:is-animation-finished
(- (:total-time screen) ego-anim-start))
is-player-wound? (= ego-anim ego-windup)
entities (stop-swing-if-necessary screen entities)]
(cond
@@ -73,18 +81,18 @@
(and
(= state :attack)
(animation! anim
:is-animation-finished
(- (:total-time screen) anim-start)))
tongue-finished?)
(-> entities
(update-in [:room :entities :tongue] #(actions/start-animation screen % :idle))
(update-in [:room :entities :tongue] assoc :state :idle :started (:total-time screen)))
(update-in [:room :entities :tongue] assoc :state :idle :started (:total-time screen))
(update-in [:room :entities :heart] #(actions/start-animation screen % :idle)))
(and
(= state :windup)
(animation! anim
:is-animation-finished
(- (:total-time screen) anim-start)))
tongue-finished?
(or (not is-player-wound?)
ego-finished?))
(-> entities
(update-in [:room :entities :tongue] #(actions/start-animation screen % :attack))
(update-in [:room :entities :tongue] assoc :state :attack :started (:total-time screen))
@@ -93,14 +101,19 @@
%))
(show-heart screen is-player-wound?))
(and (= state :idle)
is-player-wound?
ego-finished?)
(update-in entities [:room :entities :ego] #(actions/start-animation screen % :tongue-swing))
;; reset timer if you wind up while the tongue is idle
(and (= state :idle)
is-player-wound?)
(assoc-in entities [:room :entities :tongue :started] (:total-time screen))
(and (= state :idle)
(= 1 (rand-int (* 60 3)))
(> time-in-state 3.0)
(= 1 (rand-int (* 60 2)))
(> time-in-state 2.0)
(not is-player-wound?))
(-> entities
(update-in [:room :entities :tongue] #(actions/start-animation screen % :windup))
@@ -124,10 +137,11 @@
hair-7 (utils/make-anim-seq atlas "hair-7" [5 7] 0.16 [0 1 2 1])
hair-8 (utils/make-anim-seq atlas "hair-8" [6 6] 0.16 [0 1 2 1])
hair-9 (utils/make-anim-seq atlas "hair-9" [12 18] 0.16 [0 1 2 1])
heart (utils/make-anim-seq atlas "heart" [32 32] 0.16 [0])
heart (utils/make-anim-seq atlas "heart" [24 24] 0.08 [3])
beat (utils/make-anim-seq atlas "heart" [24 24] 0.08 [0 1 0 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3])
tongue-idle (utils/make-anim-seq atlas "tongue-idle/tongue-idle" [135 145] 0.16 (range 5))
tongue-windup (utils/make-anim-seq atlas "tongue-idle/tongue-idle" [135 145] 0.16 [0 0 0 0 0])
tongue-attack (utils/make-anim-seq atlas "tongue-idle/tongue-idle" [135 145] 0.16 [1 1 1 1])]
tongue-windup (utils/make-anim-seq atlas "tongue-windup" [135 145] 0.16 [0 1 0 1 0 1 0 ])
tongue-attack (utils/make-anim-seq atlas "tongue-attack" [135 145] 0.08 [0 1 2 2 2 2 2 2 2 2 2 2])]
(rooms/make :name "Tongue Fight"
@@ -226,6 +240,8 @@
:baseline 320
:opacity 0
:anim heart
:idle heart
:beat beat
:anim-start 0)
:tongue (assoc (animation->texture screen tongue-idle)
:x 186
@@ -239,11 +255,15 @@
:windup tongue-windup
:idle tongue-idle
:attack tongue-attack
:anim-merges {tongue-idle {:origin-x 23 :origin-y 10}
tongue-windup {:origin-x 23 :origin-y 10}
tongue-attack {:origin-x 119 :origin-y 10}
}
:anim-start 0
:state :idle
:script (actions/get-script
entities
(actions/play-animation entities :ego :tongue-windup)))}
(actions/begin-animation entities :ego :tongue-windup)))}
:collision "space/collision.png"
:scale-fn (constantly 1.0)