ending is beginning to be fun.

This commit is contained in:
Bryce Covert
2018-02-08 22:01:56 -08:00
67 changed files with 982 additions and 651 deletions

View File

@@ -43,88 +43,89 @@
(update-in entities [:room :entities :ego] #(actions/start-animation screen % :tongue-idle))
entities))
(defn trigger-tongue [screen {{{{:keys [state started anim anim-start]} :tongue
(defn trigger-tongue [screen {{{{:keys [state started anim anim-start] :as tongue} :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))
(if tongue
(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
(and (not (get-in entities [:fg-actions :script-running?]))
(get-in entities [:state :active?])
(= 0 ego-hearts))
(do
((actions/get-script entities (common/do-win entities)) entities)
entities)
is-player-wound? (= ego-anim ego-windup)
entities (stop-swing-if-necessary screen entities)]
(cond
(and (not (get-in entities [:fg-actions :script-running?]))
(get-in entities [:state :active?])
(= 0 ego-hearts))
(do
((common/win)
entities)
entities)
(and (not (get-in entities [:fg-actions :script-running?]))
(get-in entities [:state :active?])
(= 0 tongue-hearts))
(do
((common/win)
entities)
entities)
(and (not (get-in entities [:fg-actions :script-running?]))
(get-in entities [:state :active?])
(= 0 tongue-hearts))
(do
((common/win)
entities)
entities)
(and
(= state :attack)
tongue-finished?)
(-> entities
(update-in [:room :entities :tongue] #(actions/start-animation screen % :idle))
(update-in [:room :entities :ego] #(actions/start-animation screen % :tongue-idle))
(update-in [:room :entities :tongue] assoc :state :idle :started (:total-time screen))
(update-in [:room :entities :heart] #(actions/start-animation screen % :idle)))
(and
(= state :attack)
tongue-finished?)
(-> entities
(update-in [:room :entities :tongue] #(actions/start-animation screen % :idle))
(update-in [:room :entities :ego] #(actions/start-animation screen % :tongue-idle))
(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)
tongue-finished?
(or (not is-player-wound?)
ego-finished?))
(and
(= state :windup)
tongue-finished?
(or (not is-player-wound?)
ego-finished?))
(-> entities
(update-in [:room :entities :tongue] #(if is-player-wound?
(actions/start-animation screen % :attack-hit)
(actions/start-animation screen % :attack)))
(update-in [:room :entities :tongue] assoc :state :attack :started (:total-time screen) )
(update-in [:room :entities :ego] #(if is-player-wound?
(actions/start-animation screen % :tongue-swing)
(actions/start-animation screen % :tongue-hit)))
(show-heart screen is-player-wound?))
(-> entities
(update-in [:room :entities :tongue] #(if is-player-wound?
(actions/start-animation screen % :attack-hit)
(actions/start-animation screen % :attack)))
(update-in [:room :entities :tongue] assoc :state :attack :started (:total-time screen) )
(update-in [:room :entities :ego] #(if is-player-wound?
(actions/start-animation screen % :tongue-swing)
(actions/start-animation screen % :tongue-hit)))
(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))
(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))
;; 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 2)))
(> time-in-state 2.0)
(not is-player-wound?))
(-> entities
(update-in [:room :entities :tongue] #(actions/start-animation screen % :windup))
(update-in [:room :entities :tongue] assoc :state :windup :started (:total-time screen)))
(and (= state :idle)
(= 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))
(update-in [:room :entities :tongue] assoc :state :windup :started (:total-time screen)))
(not started)
(assoc-in entities [:room :entities :tongue :started] (:total-time screen))
:else
(not started)
(assoc-in entities [:room :entities :tongue :started] (:total-time screen))
:else
entities
)))
entities
))
entities))
(defn make [screen atlas global-atlas]
(let [hair-0 (utils/make-anim-seq atlas "hair-0" [7 8] 0.12 (range 4))
@@ -141,8 +142,12 @@
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-windup" [135 145] 0.16 [0 1 2 3 2 1 2 3 2 1 0 ])
tongue-attack (utils/make-anim-seq atlas "tongue-attack" [135 145] 0.12 [ 3 4 5 6])
tongue-attack-hit (utils/make-anim-seq atlas "tongue-attack-hit" [135 145] 0.1 (range 7))]
tongue-attack-hit (utils/make-anim-seq atlas "tongue-attack-hit" [135 145] 0.1 (range 7))
falling-bg (utils/make-anim-seq atlas "falling-bg" [128 128] 0.1 (range 6))
sword-spin (utils/make-anim-seq atlas "sword-spin" [300 238] 0.1 (range 6))]
(rooms/make :name "Tongue Fight"
@@ -150,10 +155,13 @@
:interactions {}
:layers [(assoc (utils/atlas->texture atlas "background") :x 0 :y 0 :baseline 0 :scale-x 1 :scale-y 1)]
:update-fn trigger-tongue
:ego-hearts 5
:tongue-hearts 5
:ego-hearts 1
:tongue-hearts 1
:entities {:hair-0 (assoc (animation->texture screen hair-0)
:entities {:penultimate (assoc (utils/atlas->texture atlas "penultimate") :x 0 :y 0 :baseline 2 :scale-x 1 :scale-y 1 :opacity 0)
:penultimate-wall (assoc (utils/atlas->texture atlas "penultimate-wall") :x 0 :y 0 :baseline 5 :scale-x 1 :scale-y 1 :opacity 0)
:penultimate-black (assoc (utils/atlas->texture atlas "penultimate-black") :x 0 :y 0 :baseline 6 :scale-x 1 :scale-y 1 :opacity 0)
:hair-0 (assoc (animation->texture screen hair-0)
:x 35
:y 46
:width 6
@@ -238,12 +246,36 @@
:y 29
:width 32
:height 32
:baseline 320
:baseline 321
:opacity 0
:anim heart
:idle heart
:beat beat
:anim-start 0)
:falling-bg (assoc (animation->texture screen falling-bg)
:x 0
:y 0
:width 320
:height 240
:baseline 320
:anim falling-bg
:opacity 0
:anim-start 0)
:sword-spin (assoc (animation->texture screen sword-spin)
:x 160
:y 120
:origin-x 150
:origin-y 120
:width 300
:height 238
:baseline 321
:opacity 0
:anim sword-spin
:anim-start 0)
:tongue (assoc (animation->texture screen tongue-idle)
:x 211
:y 40