Files
gitea-docker/desktop/src-common/advent/screens/rooms/behind_house.clj
Bryce Covert 023874885f tweaks.
2016-06-15 18:06:43 -07:00

153 lines
12 KiB
Clojure

(ns advent.screens.rooms.behind-house
(:require [advent.screens.rooms :as rooms]
[advent.screens.rooms.common :as common]
[advent.screens.items :as items]
[advent.actions :as actions]
[advent.utils :as utils]
[advent.steam :as steam]
[clojure.zip :as zip]
[play-clj.core :refer :all]
[play-clj.ui :refer :all]
[play-clj.utils :refer :all]
[play-clj.g2d :refer :all])
)
(defn make-night [entities]
(assoc-in entities [:room :entities :peeling :opacity] 0))
(defn make-left-dir [box]
{:box box
:script (actions/get-script
entities
(actions/walk-to entities :ego [122 140] :skip-type :end)
(actions/transition-background entities :outside-house [244 150])
(actions/walk-to entities :ego [158 110]))
:cursor :left})
(defn increment-safe-listens [entities]
(actions/update-state entities
(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])
#_:crack #_{:box [68 100 73 114]
:script (actions/get-script
entities
)}
:mushrooms {:box [247 59 269 76]
: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]
:script (actions/get-script
entities
(actions/walk-to entities :ego [128 100] :face :left)
(if (= :night (get-in @entities [:state :time]))
(actions/do-dialogue entities :ego "The house is dark and empty.")
(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.")))}}
: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
: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
: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)))
(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 Magi-safe." :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)))
(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 Magi-safe." :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.")
: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]))