more rooms using local textures.

This commit is contained in:
Bryce Covert
2017-05-28 08:28:11 -07:00
parent 135b252062
commit 7d4e93a964
3 changed files with 180 additions and 177 deletions

View File

@@ -29,147 +29,148 @@
(fn [state] (assoc state :safe-listen-count (inc (:safe-listen-count state 0))))))
(defn make [screen]
(rooms/make :music {:day :town-2 :night :night}
:name "Behind house"
:interactions
{:left-dir-1 (make-left-dir [0 48 20 240])
:left-dir-2 (make-left-dir [0 160 148 217])
:left-dir-3 (make-left-dir [130 120 154 160])
(let [[screet atlas] (utils/acquire-atlas screen "packed/behindhouse.atlas")]
(rooms/make :music {:day :town-2 :night :night}
:name "Behind house"
:interactions
{:left-dir-1 (make-left-dir [0 48 20 240])
:left-dir-2 (make-left-dir [0 160 148 217])
:left-dir-3 (make-left-dir [130 120 154 160])
#_:crack #_{:box [68 100 73 114]
:script (actions/get-script
entities
)}
:mushrooms {:box [247 59 269 76]
:label "Mushrooms"
:cursor :hand
:script (actions/get-script
entities
(if (actions/has-obtained? entities :mushrooms)
(actions/talk entities :ego "I've already got a junk ton of mushrooms.")
(do
(actions/walk-to entities :ego [242 75])
(actions/play-animation entities :ego :squat)
(actions/give entities :mushrooms)
(actions/talk entities :ego "Perfectly ripe mushrooms!"))))}
:window {:box [109 100 130 153]
:label "Window"
:cursor :look
:script (actions/get-script
entities
(actions/walk-to entities :ego [128 100] :face :left)
(cond
(= :night (get-in @entities [:state :time]))
(actions/do-dialogue entities :ego "The house is dark and empty.")
#_:crack #_{:box [68 100 73 114]
:script (actions/get-script
entities
)}
:mushrooms {:box [247 59 269 76]
:label "Mushrooms"
:cursor :hand
:script (actions/get-script
entities
(if (actions/has-obtained? entities :mushrooms)
(actions/talk entities :ego "I've already got a junk ton of mushrooms.")
(do
(actions/walk-to entities :ego [242 75])
(actions/play-animation entities :ego :squat)
(actions/give entities :mushrooms)
(actions/talk entities :ego "Perfectly ripe mushrooms!"))))}
:window {:box [109 100 130 153]
:label "Window"
:cursor :look
:script (actions/get-script
entities
(actions/walk-to entities :ego [128 100] :face :left)
(cond
(= :night (get-in @entities [:state :time]))
(actions/do-dialogue entities :ego "The house is dark and empty.")
(actions/has-obtained? entities :tune)
(actions/do-dialogue entities
:ego "Gandarf's just working on one of his spells.")
(actions/has-obtained? entities :tune)
(actions/do-dialogue entities
:ego "Gandarf's just working on one of his spells.")
(get-in @entities [:state :peeked-in-window?])
(actions/do-dialogue entities
:ego "Gandarf is moving around in the corner of the room."
:ego "I think he's opening his MagiSafe!"
:ego "I'll need a better spying angle if I hope to crack the safe.")
(get-in @entities [:state :peeked-in-window?])
(actions/do-dialogue entities
:ego "Gandarf is moving around in the corner of the room."
:ego "I think he's opening his MagiSafe!"
:ego "I'll need a better spying angle if I hope to crack the safe.")
:else
(do
(actions/do-dialogue entities
:ego "I can see Gandarf moving around in the corner of the room."
:ego "It's hard to make out from this angle.")
(actions/update-state entities #(assoc % :peeked-in-window? true)))))}}
:layers {:day [(assoc (utils/get-texture "behindhouse/background.png") :x 0 :y 0 :baseline 0)
(assoc (utils/get-texture "behindhouse/house.png") :x 0 :y 0 :baseline 122)
(assoc (utils/get-texture "behindhouse/brush.png") :x 0 :y 0 :baseline 240)
(assoc (utils/get-texture "behindhouse/fgleft.png") :x -10 :y 0 :baseline 240 :parallax 1.5)
(assoc (utils/get-texture "behindhouse/fg2.png") :x (- 320 122) :y 0 :baseline 240 :parallax 1.5)]
:night [(assoc (utils/get-texture "behindhouse/background.png") :x 0 :y 0 :baseline 0)
(assoc (utils/get-texture "behindhouse/house.png") :x 0 :y 0 :baseline 122)
(assoc (utils/get-texture "behindhouse/brush.png") :x 0 :y 0 :baseline 240)
(assoc (utils/get-texture "behindhouse/fgleft.png") :x -10 :y 0 :baseline 240 :parallax 1.5)
(assoc (utils/get-texture "behindhouse/fg2.png") :x (- 320 122) :y 0 :baseline 240 :parallax 1.5)]}
:entities {:stick (assoc (utils/get-texture "behindhouse/stick.png")
:x 26 :y 80 :baseline 160
:label "Stick"
:cursor :hand
:script (actions/get-script entities
(actions/walk-to entities :ego [50 80])
(actions/play-animation entities :ego :reach)
(actions/remove-entity entities :stick)
(actions/give entities :stick)
(actions/talk entities :ego "This stick might be useful.")))
:peeling (assoc (utils/get-texture "behindhouse/house-cover.png")
:x 60 :y 92 :baseline 148
:label "Crumbly wall"
:cursor :hand
:script (actions/get-script entities
(cond (= :night (get-in @entities [:state :time]))
(actions/talk entities :ego "The house is empty right now.")
:else
(do
(actions/do-dialogue entities
:ego "I can see Gandarf moving around in the corner of the room."
:ego "It's hard to make out from this angle.")
(actions/update-state entities #(assoc % :peeked-in-window? true)))))}}
:layers {:day [(assoc (utils/atlas->texture atlas "background") :x 0 :y 0 :baseline 0)
(assoc (utils/atlas->texture atlas "house") :x 0 :y 0 :baseline 122)
(assoc (utils/atlas->texture atlas "brush") :x 0 :y 0 :baseline 240)
(assoc (utils/atlas->texture atlas "fgleft") :x -10 :y 0 :baseline 240 :parallax 1.5)
(assoc (utils/atlas->texture atlas "fg2") :x (- 320 122) :y 0 :baseline 240 :parallax 1.5)]
:night [(assoc (utils/atlas->texture atlas "background") :x 0 :y 0 :baseline 0)
(assoc (utils/atlas->texture atlas "house") :x 0 :y 0 :baseline 122)
(assoc (utils/atlas->texture atlas "brush") :x 0 :y 0 :baseline 240)
(assoc (utils/atlas->texture atlas "fgleft") :x -10 :y 0 :baseline 240 :parallax 1.5)
(assoc (utils/atlas->texture atlas "fg2") :x (- 320 122) :y 0 :baseline 240 :parallax 1.5)]}
:entities {:stick (assoc (utils/atlas->texture atlas "stick")
:x 26 :y 80 :baseline 160
:label "Stick"
:cursor :hand
:script (actions/get-script entities
(actions/walk-to entities :ego [50 80])
(actions/play-animation entities :ego :reach)
(actions/remove-entity entities :stick)
(actions/give entities :stick)
(actions/talk entities :ego "This stick might be useful.")))
:peeling (assoc (utils/atlas->texture atlas "house-cover")
:x 60 :y 92 :baseline 148
:label "Crumbly wall"
:cursor :hand
:script (actions/get-script entities
(cond (= :night (get-in @entities [:state :time]))
(actions/talk entities :ego "The house is empty right now.")
(and (get-in @entities [:state :opened-crack?])
(= 0 (get-in @entities [:state :safe-listen-count] 0)))
(and (get-in @entities [:state :opened-crack?])
(= 0 (get-in @entities [:state :safe-listen-count] 0)))
(do (actions/walk-to entities :ego [70 80])
(actions/play-animation entities :ego :start-squat :stop? false)
(actions/talk entities :ego "I can see Gandarf the wizard inside." :animate? false :stop? false)
(actions/talk entities :ego "It looks like he's opening his MagiSafe." :animate? false :stop? false)
(actions/play-safe entities false)
(actions/talk entities :ego "So that's the code to his safe..." :animate? false :stop? false)
(actions/play-animation entities :ego :end-squat)
(actions/talk entities :ego "A lot of good it'll do me to know his password while he's still there.")
(steam/set-achievement "SAFE_AND_SOUND")
(increment-safe-listens entities))
(do (actions/walk-to entities :ego [70 80])
(actions/play-animation entities :ego :start-squat :stop? false)
(actions/talk entities :ego "I can see Gandarf the wizard inside." :animate? false :stop? false)
(actions/talk entities :ego "It looks like he's opening his MagiSafe." :animate? false :stop? false)
(actions/play-safe entities false)
(actions/talk entities :ego "So that's the code to his safe..." :animate? false :stop? false)
(actions/play-animation entities :ego :end-squat)
(actions/talk entities :ego "A lot of good it'll do me to know his password while he's still there.")
(steam/set-achievement "SAFE_AND_SOUND")
(increment-safe-listens entities))
(and (get-in @entities [:state :opened-crack?])
(= 1 (get-in @entities [:state :safe-listen-count] 0)))
(and (get-in @entities [:state :opened-crack?])
(= 1 (get-in @entities [:state :safe-listen-count] 0)))
(do (actions/walk-to entities :ego [70 80])
(actions/talk entities :ego "I'll give it another listen.")
(actions/play-animation entities :ego :start-squat :stop? false)
(actions/talk entities :ego "It looks like Gandarf's opening his MagiSafe." :animate? false :stop? false)
(actions/play-safe entities false)
(actions/play-animation entities :ego :end-squat)
(actions/talk entities :ego "Ugh! Now I've got it stuck in my head!")
(increment-safe-listens entities)
(actions/give entities :tune))
(do (actions/walk-to entities :ego [70 80])
(actions/talk entities :ego "I'll give it another listen.")
(actions/play-animation entities :ego :start-squat :stop? false)
(actions/talk entities :ego "It looks like Gandarf's opening his MagiSafe." :animate? false :stop? false)
(actions/play-safe entities false)
(actions/play-animation entities :ego :end-squat)
(actions/talk entities :ego "Ugh! Now I've got it stuck in my head!")
(increment-safe-listens entities)
(actions/give entities :tune))
(get-in @entities [:state :opened-crack?])
(actions/talk entities :ego "I've got the tune stuck in my head already.")
(get-in @entities [:state :opened-crack?])
(actions/talk entities :ego "I've got the tune stuck in my head already.")
:else
(do (actions/walk-to entities :ego [80 80] :face :left)
(actions/talk entities :ego "It looks like the wall is crumbling here.")
(actions/play-animation entities :ego :reach)
(actions/update-entity entities :peeling #(assoc % :opacity 0))
(actions/update-state entities (fn [state] (assoc state :opened-crack? true))))))
:scripts {:stick (actions/get-script entities
(if (get-in @entities [:state :opened-crack?])
(actions/talk entities :ego "I could shove the stick in that hole, but why?")
(actions/do-dialogue entities
:ego "It looks like that wall is crumbling."
:ego "I can probably scratch it off with my hand.")))
:sword (actions/get-script entities
(actions/do-dialogue entities
:ego "I should be careful with this sword."
:ego "It's sharp!"))})
:bird (utils/make-bird screen [[50 235] [80 220] [100 239] [180 235] [85 225]])
:outside-particles (common/make-outside-particles)}
:collision "behindhouse/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)
:apply-state (fn [_ entities]
(utils/fast-forward-particle (get-in entities [:room :entities :outside-particles]))
(as-> entities entities
(if (get-in entities [:state :opened-crack?])
(assoc-in entities [:room :entities :peeling :opacity] 0)
entities)
(if (actions/has-obtained? entities :stick)
(update-in entities [:room :entities] #(dissoc % :stick))
entities)
(if (= :night (get-in entities [:state :time]))
(make-night entities)
entities)))
:start-pos [172 122]))
:else
(do (actions/walk-to entities :ego [80 80] :face :left)
(actions/talk entities :ego "It looks like the wall is crumbling here.")
(actions/play-animation entities :ego :reach)
(actions/update-entity entities :peeling #(assoc % :opacity 0))
(actions/update-state entities (fn [state] (assoc state :opened-crack? true))))))
:scripts {:stick (actions/get-script entities
(if (get-in @entities [:state :opened-crack?])
(actions/talk entities :ego "I could shove the stick in that hole, but why?")
(actions/do-dialogue entities
:ego "It looks like that wall is crumbling."
:ego "I can probably scratch it off with my hand.")))
:sword (actions/get-script entities
(actions/do-dialogue entities
:ego "I should be careful with this sword."
:ego "It's sharp!"))})
:bird (utils/make-bird screen [[50 235] [80 220] [100 239] [180 235] [85 225]])
:outside-particles (common/make-outside-particles)}
:collision "behindhouse/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)
:apply-state (fn [_ entities]
(utils/fast-forward-particle (get-in entities [:room :entities :outside-particles]))
(as-> entities entities
(if (get-in entities [:state :opened-crack?])
(assoc-in entities [:room :entities :peeling :opacity] 0)
entities)
(if (actions/has-obtained? entities :stick)
(update-in entities [:room :entities] #(dissoc % :stick))
entities)
(if (= :night (get-in entities [:state :time]))
(make-night entities)
entities)))
:start-pos [172 122])))

View File

@@ -132,11 +132,12 @@
{:run #(actions/do-dialogue entities :ego %)}]}))
(defn make [screen]
(let [
safe-lock (utils/make-anim "inside-house/safe-lock.png" [11 8] 0.1 (flatten [(repeat 20 0) 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 (range 3 20) 20 20 20 20 21 21 21 21 21 20 20 21 21 21 21 21 20 20 20 ]))
candle (utils/make-anim "inside-house/candle.png" [34 32] 0.2 [1 0 1 2])
candle-aura (utils/make-anim "inside-house/candle-aura.png" [27 27] 0.2 [0 1 2 3 2 1] )
experiment-left (utils/flip (utils/make-anim-seq "wizard/experiment" [45 55] 0.075 [0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 3 3 3 4 4 5 5 6 6 6 6 6 6 7 8 9 9 10 10 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 14 14 14 14 14 15 15 16 16 17 17 18 18 18 18 19 20 21 21 21 21 21 21 22 23 22 23 22 23 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 26 27 37 38 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 28 28 28 28 29 29 28 28 28 28 28 28 28 28 30 30 30 30 31 32 33 31 31 31 31 31 31 31 31 34 35 36 36 36 36 36 36 36 36 36] ))]
(let [[screen atlas] (utils/acquire-atlas screen "packed/inside-house.atlas")
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
safe-lock (utils/make-anim atlas "safe-lock" [11 8] 0.1 (flatten [(repeat 20 0) 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 (range 3 20) 20 20 20 20 21 21 21 21 21 20 20 21 21 21 21 21 20 20 20 ]))
candle (utils/make-anim atlas "candle" [34 32] 0.2 [1 0 1 2])
candle-aura (utils/make-anim atlas "candle-aura" [27 27] 0.2 [0 1 2 3 2 1] )
experiment-left (utils/flip (utils/make-anim-seq global-atlas "wizard/experiment" [45 55] 0.075 [0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 3 3 3 4 4 5 5 6 6 6 6 6 6 7 8 9 9 10 10 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 14 14 14 14 14 15 15 16 16 17 17 18 18 18 18 19 20 21 21 21 21 21 21 22 23 22 23 22 23 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 26 27 37 38 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 28 28 28 28 29 29 28 28 28 28 28 28 28 28 30 30 30 30 31 32 33 31 31 31 31 31 31 31 31 34 35 36 36 36 36 36 36 36 36 36] ))]
(rooms/make :music :inside-fangald
:name "Inside house"
:interactions {:down-dir {:box [151 0 320 40]
@@ -175,43 +176,44 @@
:cursor :look
:script (actions/get-script entities
(actions/talk entities :ego "It's a really big window!"))}}
:layers [(assoc (utils/get-texture "inside-house/background.png") :x 0 :y 0 :baseline 0)
(assoc (utils/get-texture "inside-house/desk.png") :x 0 :y 0 :baseline 200)
(assoc (utils/get-texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240 :parallax 2.0)
(assoc (utils/get-texture "inside-house/glow.png") :x 0 :y 0 :baseline 199 :additive? true)]
:layers [(assoc (utils/atlas->texture atlas "background") :x 0 :y 0 :baseline 0)
(assoc (utils/atlas->texture atlas "desk") :x 0 :y 0 :baseline 200)
(assoc (utils/atlas->texture atlas "sillhoute") :x 0 :y 0 :baseline 240 :parallax 2.0)
(assoc (utils/atlas->texture atlas "glow") :x 0 :y 0 :baseline 199 :additive? true)]
:entities {
:wizard (common/make-wizard screen {:x 228 :y 60 :baseline 160 :scale-x 1.75 :scale-y 1.75 :origin-x 0 :origin-y 0
:script (actions/get-script entities (do-wizard-dialogue entities))
:scripts #(condp = %
:kiss (actions/get-script entities
(actions/do-dialogue entities
:wizard "Good job, boy! You saved a damsel in distress."
:wizard "You have proven yourself worthy in courage."))
:medal (actions/get-script entities
(actions/do-dialogue entities
:wizard "So you beat Captain McHulk at arm wrestling? "
:wizard "You must have been working out!"))
:trophy (actions/get-script entities
(actions/do-dialogue entities
:wizard "My, my, you have proven your worth in wisdom!"
:wizard "One day, you'll be as wise as I am!"))
:recipe (actions/get-script entities
(actions/do-dialogue entities
:ego "I probably shouldn't show him that I have his stolen possessions."))
:frog-legs (actions/get-script entities
(actions/do-dialogue entities
:ego "I probably shouldn't show him that I have his stolen possessions."))
:mandrake (actions/get-script entities
(actions/do-dialogue entities
:ego "I probably shouldn't show him that I have his stolen possessions."))
:flask-1 (actions/get-script entities
(actions/do-dialogue entities
:wizard "You can keep the flask."))
:tune (actions/get-script entities
(actions/talk entities :ego "I think he already has it memorized."))
(actions/get-script entities
:wizard (common/make-wizard screen global-atlas
{:x 228 :y 60 :baseline 160 :scale-x 1.75 :scale-y 1.75 :origin-x 0 :origin-y 0
:script (actions/get-script entities (do-wizard-dialogue entities))
:scripts #(condp = %
:kiss (actions/get-script entities
(actions/do-dialogue entities
:wizard "Good job, boy! You saved a damsel in distress."
:wizard "You have proven yourself worthy in courage."))
:medal (actions/get-script entities
(actions/do-dialogue entities
:wizard "No thank you.")))})
:wizard "So you beat Captain McHulk at arm wrestling? "
:wizard "You must have been working out!"))
:trophy (actions/get-script entities
(actions/do-dialogue entities
:wizard "My, my, you have proven your worth in wisdom!"
:wizard "One day, you'll be as wise as I am!"))
:recipe (actions/get-script entities
(actions/do-dialogue entities
:ego "I probably shouldn't show him that I have his stolen possessions."))
:frog-legs (actions/get-script entities
(actions/do-dialogue entities
:ego "I probably shouldn't show him that I have his stolen possessions."))
:mandrake (actions/get-script entities
(actions/do-dialogue entities
:ego "I probably shouldn't show him that I have his stolen possessions."))
:flask-1 (actions/get-script entities
(actions/do-dialogue entities
:wizard "You can keep the flask."))
:tune (actions/get-script entities
(actions/talk entities :ego "I think he already has it memorized."))
(actions/get-script entities
(actions/do-dialogue entities
:wizard "No thank you.")))})
:safe-lock (actions/start-animation screen (assoc (animation->texture screen safe-lock) :x 50 :y 92 :baseline 145
:stand safe-lock)
:stand)
@@ -231,7 +233,7 @@
:magic-frog-particle (doto (assoc (particle-effect "particles/magic-frog") :x 230 :y 0
:baseline 241)
(particle-effect! :set-position 237 0))
:flask (assoc (utils/get-texture "inside-house/flask.png")
:flask (assoc (utils/atlas->texture atlas "flask")
:x 265 :y 80 :baseline 240
:label "Flask"
:cursor :hand
@@ -241,7 +243,7 @@
(when (get-in @entities [:room :entities :wizard])
(actions/do-dialogue entities :ego "Hey, you think I could have this flask?"
:wizard "Sure."))))
:frog-legs (assoc (utils/get-texture "inside-house/frog-legs.png")
:frog-legs (assoc (utils/atlas->texture atlas "frog-legs")
:x 180 :y 77 :baseline 240
:label "Frog legs"
:cursor :hand

View File

@@ -392,7 +392,7 @@
([atlas file [w h] speed frames]
(animation speed (split-texture atlas file [w h] frames))))
=
(defn make-bird [screen p]
(let [bird-sheet (texture! (get-texture "outside-castle/bird.png") :split 1 2)
bird-stand (animation 0.15 (for [i [0 1]]