Adding more of the nighttime puzzle.

This commit is contained in:
2014-12-28 12:23:03 -08:00
parent bc55fa4c28
commit 5debdd60dd
19 changed files with 182 additions and 92 deletions

View File

@@ -1,6 +1,7 @@
(ns advent.screens.rooms.outside-house
(:require [advent.screens.items :as items]
[advent.screens.rooms :as rooms]
[advent.screens.rooms.common :as common]
[advent.actions :as actions]
[advent.utils :as utils]
[clojure.zip :as zip]
@@ -112,8 +113,49 @@
(actions/respond entities % :wizard "Now scram!")
(actions/transition-background entities :outside-house [262 88]))}]}))
(defn talk-to-gandarf-outside [entities]
(actions/walk-to entities :ego [120 80] :face :right)
(if (actions/has-item? entities :flask-2)
(actions/do-dialogue entities :wizard "Have you gotten me water from the fountain yet?"
:ego "No, not yet."
:wizard "Hurry, boy! Time's-a-wastin'!")
(do
(actions/do-dialogue entities :ego "Gandarf! Boy am I glad to see you."
:wizard "There is no time, boy."
:wizard "We must hurry if you are to defeat Blergh."
:ego "Wait, you knew about Blergh all along?"
:ego "And you never told me?"
:wizard "Honestly, I've always thought you were a loser."
:wizard "I never thought you'd be able to pull the sword."
:wizard "But we have to hurry."
:wizard "Blergh spent his entire time in sword prison making that helmet that zapped you."
:wizard "There's only one way to neutralize it:"
:wizard "The Slinger's Shot."
:wizard "It's a magical slingshot that has long lost its power."
:wizard "You and me, boy, we're going to return it to its powerful state."
:wizard "Then you can beat Blergh, come sunrise."
:wizard "Now, time is of the essence."
:wizard "Take this flask. Fill it with water from the fountain.")
(actions/give entities :flask-2))))
(defn add-wizard-if-necessary [entities]
(if (actions/has-item? entities :flask-water)
entities
(update-in entities [:room :entities] #(assoc % :wizard (get-in entities [:room :wizard])))))
(defn add-note-if-necessary [entities]
(if (and (actions/has-item? entities :flask-water)
(not (actions/has-obtained? entities :note-1)))
(update-in entities [:room :entities] #(assoc % :note (get-in entities [:room :note])))
entities))
(defn make-night [entities]
(update-in entities [:room :entities] #(dissoc % :butterfly)))
(-> entities
(update-in [:room :entities] #(dissoc % :butterfly))
(update-in [:room :entities] #(assoc % :cauldron (get-in entities [:room :cauldron])))
add-wizard-if-necessary
add-note-if-necessary))
(defn make [screen]
(let [sheep-stand-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21)
@@ -122,7 +164,8 @@
(aget sheep-stand-sheet 0 i)))
sheep-walk (animation 0.05 (for [i (range 6)]
(aget sheep-walk-sheet 0 i)))
butterfly-stand (utils/make-anim "butterfly.png" [7 7] 0.1 [0 1])]
butterfly-stand (utils/make-anim "butterfly.png" [7 7] 0.1 [0 1])
cauldron (utils/make-anim "outsidehouse/cauldron.png" [50 38] 0.15 (range 4))]
(rooms/make :music :town-2
:interactions
{:door {:box [258 100 281 160]
@@ -237,6 +280,27 @@
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)))))}
:cauldron (rooms/make-entity :cauldron (assoc (animation->texture screen cauldron)
:x 139 :y 73 :baseline 167
:anim cauldron
:anim-start 0
:script (actions/get-script entities (actions/talk entities :ego "That's a big cauldron!"))
:scripts {:recipe (actions/get-script entities
(actions/walk-to entities :ego [151 90] :face :right)
(actions/play-animation entities :ego :squat)
(actions/remove-item entities :recipe)
(actions/give entities :ash)
(actions/talk entities :ego "It burned up into ash."))}))
:wizard (rooms/make-entity :wizard (common/make-wizard screen {:x 190 :y 78 :baseline 162 :scale-x 1.2 :scale-y 1.2
:script (actions/get-script entities (talk-to-gandarf-outside entities))}))
:note (rooms/make-entity :note (assoc (texture "outsidehouse/note.png")
:x 286 :y 80 :baseline 160
:script (actions/get-script entities
(actions/walk-to entities :ego [280 80] :face :right)
(actions/play-animation entities :ego :squat)
(actions/remove-entity entities :note)
(actions/give entities :note-1)
(common/read-note-1 entities))))
:collision "outsidehouse/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)
:apply-state (fn [entities]