started process of night time exclusions.

This commit is contained in:
2014-12-27 22:59:50 -08:00
parent b20d8528ea
commit 8890961114
4 changed files with 37 additions and 23 deletions

View File

@@ -11,10 +11,11 @@
[play-clj.ui :refer :all] [play-clj.ui :refer :all]
[play-clj.utils :refer :all] [play-clj.utils :refer :all]
[play-clj.g2d :refer :all])) [play-clj.g2d :refer :all]))
(defn remove-lock [entities] (defn remove-lock [entities]
(-> entities (-> entities
(update-in [:room :interactions] (utils/remove-interaction :lock)
(fn [i] (remove #(= :lock (:id %)) i)))
(assoc-in [:room :collision] (get-in entities [:room :collision-free])))) (assoc-in [:room :collision] (get-in entities [:room :collision-free]))))
(defn open-lock [entities] (defn open-lock [entities]

View File

@@ -119,6 +119,12 @@
(get-in @entities [:state :wants-toy]) (do-wants-toy-conversation entities) (get-in @entities [:state :wants-toy]) (do-wants-toy-conversation entities)
:else (do-initial-peddler-conversation entities))) :else (do-initial-peddler-conversation entities)))
(defn make-night [entities]
(-> entities
(update-in [:room :entities] #(dissoc % :peddler))
(update-in [:room :entities] #(dissoc % :balloons))
(utils/remove-interaction :wares)))
(defn make [screen] (defn make [screen]
(let [peddler-sheet (texture! (texture "outside-castle/peddler-talk.png" ) :split 18 36) (let [peddler-sheet (texture! (texture "outside-castle/peddler-talk.png" ) :split 18 36)
peddler-talk (animation 0.18 (for [i (flatten [2 3 2 3 2 3 6 1 0 1 0 1 0 1 0 1 2 3 2 3 2 3 6 4 5 4 5 4 5 4 5])] peddler-talk (animation 0.18 (for [i (flatten [2 3 2 3 2 3 6 1 0 1 0 1 0 1 0 1 2 3 2 3 2 3 6 4 5 4 5 4 5 4 5])]
@@ -166,8 +172,13 @@
(actions/talk entities :ego "Hey! Carrots.") (actions/talk entities :ego "Hey! Carrots.")
(actions/play-animation entities :ego :squat) (actions/play-animation entities :ego :squat)
(actions/talk entities :ego "No one will notice one missing.") (actions/talk entities :ego "No one will notice one missing.")
(actions/give entities :carrot))))} (actions/give entities :carrot))))}}
:peddler {:box [110 90 128 146] :layers {:day [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)]
:night [(assoc (texture "outside-castle/background-dark.png") :x 0 :y 0 :baseline 0)]}
:entities {:peddler (actions/start-animation screen
(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil
:talk peddler-talk :stand peddler-stand
:talk-color (color 1.0 0.9 0.4 1.0)
:script (actions/get-script :script (actions/get-script
entities entities
(walk-to-peddler entities) (walk-to-peddler entities)
@@ -184,13 +195,7 @@
(walk-to-peddler entities) (walk-to-peddler entities)
(actions/do-dialogue entities (actions/do-dialogue entities
:ego "Are you interested in this?" :ego "Are you interested in this?"
:peddler "No, I have no use for it.")))}} :peddler "No, I have no use for it."))))
:layers {:day [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)]
:night [(assoc (texture "outside-castle/background-dark.png") :x 0 :y 0 :baseline 0)]}
:entities {:peddler (actions/start-animation screen
(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil
:talk peddler-talk :stand peddler-stand
:talk-color (color 1.0 0.9 0.4 1.0))
:stand) :stand)
:steer (actions/start-animation screen (assoc (animation->texture screen steer-stand) :x 203 :y 155 :baseline 80 :steer (actions/start-animation screen (assoc (animation->texture screen steer-stand) :x 203 :y 155 :baseline 80
@@ -237,4 +242,8 @@
:baseline 240)} :baseline 240)}
:collision "outside-castle/collision.png" :collision "outside-castle/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00) :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)
:start-pos [310 80]))) :start-pos [310 80]
:apply-state (fn [entities]
(if (= :night (get-in entities [:state :time]))
(make-night entities)
entities)))))

View File

@@ -298,6 +298,7 @@
{:object nil {:object nil
:active? true :active? true
:last-room :outside-house :last-room :outside-house
:time :day
:obtained-items #{} :obtained-items #{}
:inventory [] :inventory []
:clues #{} :clues #{}

View File

@@ -111,3 +111,6 @@
(assoc-in entities [:cursor :override] (:cursor mouse-override)) (assoc-in entities [:cursor :override] (:cursor mouse-override))
(assoc-in entities [:cursor :override] nil))) (assoc-in entities [:cursor :override] nil)))
entities)) entities))
(defn remove-interaction [entities id]
(update-in entities [:room :interactions] (fn [i] (remove #(= id (:id %)) i))))