drops the coin correctly.

This commit is contained in:
Bryce Covert
2015-07-30 09:05:41 -07:00
parent e7629b8c96
commit a19f7ebd41
6 changed files with 56 additions and 23 deletions

View File

@@ -5,4 +5,5 @@
+ Brian O'Brainy animation
+ proper save/settings file location
+ closing should stop all scripts
+ frankie should drop coin
+ dialogue for coin drop
+ night gandarf text is bad

View File

@@ -106,6 +106,14 @@
:origin-x 5
:origin-y 5
:night-profile :none
:update-fn (partial utils/update-path-location 0.5)
:script (actions/get-script entities
(when (get-in @entities [:state :has-dropped-coin?])
(actions/walk-to entities :ego [196 46] :face :left)
(actions/play-animation entities :ego :squat)
(actions/remove-entity entities :coin-flip)
(actions/give entities :money)))
:walk coin-flip
:coinflip coin-flip)))
(defn make-goon-1 [screen]
@@ -138,12 +146,26 @@
(actions/start-animation s e :stand)
e))
:script (actions/get-script entities
(if (= (get-in @entities [:room :entities :coin-flip :opacity]) 1.0)
(actions/update-entities entities
(fn [screen entities]
(let [current-y (get-in entities [:room :entities :coin-flip :y])]
(assoc-in entities [:tweens :coin-y] (tween/tween :coin-y screen [:room :entities :coin-flip :y] current-y 80 0.5 :ease tween/ease-in-cubic))))
:use-screen? true)
(if (get-in @entities [:tweens :coin-y])
(do
(actions/update-entities entities (fn [entities]
(update-in entities [:tweens] dissoc :coin-y)))
(actions/walk-straight-to entities :coin-flip [212 90] :update-baseline? false :speed 3.0)
(actions/walk-straight-to entities :coin-flip [210 105] :update-baseline? false :speed 1.0)
(Thread/sleep 50)
(actions/walk-straight-to entities :coin-flip [205 75] :update-baseline? false :speed 1.5)
(actions/walk-straight-to entities :coin-flip [202 83] :update-baseline? false :speed 1.0)
(Thread/sleep 50)
(actions/walk-straight-to entities :coin-flip [195 65] :update-baseline? false :speed 0.5)
(actions/walk-straight-to entities :coin-flip [192 70] :update-baseline? false :speed 0.5)
(Thread/sleep 50)
(actions/walk-straight-to entities :coin-flip [185 44] :update-baseline? false :speed 0.5)
(actions/update-state entities (fn [s] (assoc s :has-dropped-coin? true))))
(actions/talk entities :ego "Hey goon!")))
:night-profile :sprite
:anim-start 0
@@ -156,15 +178,17 @@
(actions/walk-to entities :ego [245 90]))
(defn flip-coin [screen entities]
(-> entities
(update-in [:room :entities :coin-flip] (fn [cf] (-> (actions/start-animation screen cf :coinflip)
(assoc :opacity 1.0))))
(assoc-in [:tweens :coin-y] (tween/tween :coin-y screen [:room :entities :coin-flip :y] 112 175 0.5 :ease tween/ease-out-cubic
:finish (fn [e]
(assoc-in e [:tweens :coin-y] (tween/tween :coin-y (assoc screen :total-time (+ 0.5 (:total-time screen))) [:room :entities :coin-flip :y] 174 112 0.5 :ease tween/ease-in-cubic
(if (not (get-in entities [:state :has-dropped-coin?]))
(-> entities
(update-in [:room :entities :coin-flip] (fn [cf] (-> (actions/start-animation screen cf :coinflip)
(assoc :opacity 1.0))))
(assoc-in [:tweens :coin-y] (tween/tween :coin-y screen [:room :entities :coin-flip :y] 112 175 0.5 :ease tween/ease-out-cubic
:finish (fn [e]
(assoc-in e [:tweens :coin-y] (tween/tween :coin-y (assoc screen :total-time (+ 0.5 (:total-time screen))) [:room :entities :coin-flip :y] 174 116 0.5 :ease tween/ease-in-cubic
:finish (fn [e]
(assoc-in e [:room :entities :coin-flip :opacity] 0.0)))))))
(update-in [:room :entities :goon-2] (fn [g] (-> (actions/start-animation screen g :flip))))))
(update-in [:room :entities :goon-2] (fn [g] (-> (actions/start-animation screen g :flip)))))
entities))
(defn make [screen]
@@ -233,5 +257,13 @@
(actions/has-obtained? entities :walkie-talkies))
(assoc-in entities [:room :entities :walkie-talkies]
(get-in entities [:room :walkie-talkies]))
entities)
(if (and (not (actions/has-obtained? entities :money))
(get-in entities [:state :has-dropped-coin?]))
(do
(update-in entities [:room :entities :coin-flip] assoc :x 185 :y 44 :opacity 1.0))
entities)
(if (actions/has-obtained? entities :money)
(update-in entities [:room :entities] dissoc :coin-flip)
entities)))
:start-pos [300 45])))

View File

@@ -213,9 +213,7 @@
:ego "No, not the Slinger's Shot!"
:frankie "Look like we hit the jackpot tonight boys!")
(frankie-comment-on-item entities)
(actions/give entities :money)
(actions/do-dialogue entities
:frankie "Here's a little tip for your troubles, Dipstick."
:frankie "Bubba, put this stuff in the secret stash."
:frankie "Now move along."
:frankie "Before we decide to take all of your stuff."

View File

@@ -270,12 +270,12 @@
(actions/give entities :flask-2))))
(defn add-wizard-if-necessary [entities]
(if (actions/has-obtained? entities :money)
(if (get-in entities [:state :seen-frankie?])
entities
(update-in entities [:room :entities] #(assoc % :wizard (get-in entities [:room :wizard])))))
(defn add-note-if-necessary [entities]
(if (and (actions/has-obtained? entities :money)
(if (and (get-in entities [:state :seen-frankie?])
(not (actions/has-obtained? entities :note-1)))
(update-in entities [:room :entities] #(assoc % :note (get-in entities [:room :note])))
entities))

View File

@@ -149,10 +149,12 @@
)
(defn update-path-location [speed screen entities entity]
(let [pos-f (- (path-point speed screen entities entity) (int (* (- (:total-time screen) (:path-start-time entity 0.0)) speed)))
v (vector-2 0 0)
a (catmull-rom-spline! (:path entity) :value-at v pos-f)]
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y))))
(if (:path entity)
(let [pos-f (- (path-point speed screen entities entity) (int (* (- (:total-time screen) (:path-start-time entity 0.0)) speed)))
v (vector-2 0 0)
a (catmull-rom-spline! (:path entity) :value-at v pos-f)]
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y)))
entity))
(defn find-override [entities [x y]]
(first (concat (filter #(and ((:mouse-in? %) entities x y)

View File

@@ -1 +1 @@
{:active? true, :coaxed-sheep? true, :seen-bloodclot? true, :seen-frankie? true, :plaques-read #{:shovel}, :convinced-wizard? true, :time :night, :opened-bars? true, :inventory (:note-1 :money :flask-2 :key :rope :crowbar :sword :recipe :kiss :ladder :cat-toy), :seen-intro? true, :wizard-left? false, :dropped-ball? true, :hay-searches 1, :clues #{:name}, :hud-active? false, :allowed-to-keep-teddy? true, :warden-sleeping? true, :current-riddle :done, :warden-fast-asleep? true, :last-room :outside-jail, :wants-toy true, :bent-bars? true, :chest-contents [], :mints-eaten 0, :object nil, :obtained-items #{:balloon :money :flask-2 :flask-1-with-cream-of-mushroom :key :slingshot :teddy :recipe :mushrooms :rope :flask-1-with-milk :kiss :wool :portrait :slobber :medal :sword :frog-legs :flask-1 :flask-1-strength :dream-sword :mandrake :shovel :cat-toy :grass :stick :motivational-tapes :ladder :carrot :trophy :crowbar :note-1 :flask-1-slobber :ball-n-chain}}
{:active? true, :coaxed-sheep? true, :seen-bloodclot? true, :plaques-read #{:shovel}, :convinced-wizard? true, :time :night, :opened-bars? true, :inventory (:note-1 :key :rope :crowbar :sword :recipe :kiss :ladder :cat-toy), :seen-intro? true, :wizard-left? false, :dropped-ball? true, :hay-searches 1, :clues #{:name}, :hud-active? false, :allowed-to-keep-teddy? true, :warden-sleeping? true, :current-riddle :done, :warden-fast-asleep? true, :last-room :outside-jail, :wants-toy true, :bent-bars? true, :chest-contents [], :mints-eaten 0, :object nil, :obtained-items #{:balloon :flask-1-with-cream-of-mushroom :key :slingshot :teddy :recipe :mushrooms :rope :flask-1-with-milk :kiss :wool :portrait :slobber :medal :sword :frog-legs :flask-1 :flask-1-strength :dream-sword :mandrake :shovel :cat-toy :grass :stick :motivational-tapes :ladder :carrot :trophy :crowbar :note-1 :flask-1-slobber :ball-n-chain}}