Files
gitea-docker/desktop/src-common/advent/screens/rooms/dream.clj
2015-03-11 18:20:40 -07:00

92 lines
7.5 KiB
Clojure

(ns advent.screens.rooms.dream
(:require
[clojure.core.async :as a]
[advent.screens.rooms :as rooms]
[advent.screens.rooms.common :as common]
[advent.actions :as actions]
[advent.screens.items :as items]
[advent.utils :as utils]
[clojure.zip :as zip]
[clojure.set :as set]
[clojure.string :as str]
[play-clj.core :refer :all]
[play-clj.math :refer :all]
[play-clj.ui :refer :all]
[play-clj.utils :refer :all]
[play-clj.g2d :refer :all]))
(def walk-chan (a/chan))
(defn do-intro [entities]
(a/go
(actions/do-dialogue entities
:ego "Oh hi there!"
:ego "I'm Faceplant, the great knight, and this is my dream!"
:ego "Just like in real life, I can walk around if you just click somewhere on the screen."
:ego "Give it a shot, whydontya?")
(actions/walk-to entities :ego [100 100])
(actions/talk entities :ego "I can also pick up stuff by clicking on it.")))
(defn make [screen]
(let [fairy-godfather-anim (utils/make-anim "dream/fairy-godfather.png" [63 77] 0.15 [0 1 2 3 2 1 0 1 4 3 2 1])
fairy-godfather-talk-anim (utils/make-anim "dream/fairy-godfather.png" [63 77] 0.15 [5 6 7 8 7 6])]
(rooms/make :music :town-1
:interactions {}
:layers [(assoc (texture "dream/clouds1.png") :x -10 :y 0 :baseline -1 :parallax 0.2 :scale-x 1.1 :scale-y 1.1)
(assoc (texture "dream/island.png") :x 180 :y 180 :baseline 0 :parallax 0.3 :scale-x 1.1 :scale-y 1.1)
(assoc (texture "dream/cliff.png") :x 50 :y 133 :baseline 1 :parallax 0.6 :scale-x 1.2 :scale-y 1.2)
(assoc (texture "dream/background.png") :x 0 :y 0 :baseline 2)
(assoc (texture "dream/corner-l.png") :x -10 :y -10 :baseline 240 :parallax 2.0)
(assoc (texture "dream/corner-r.png") :x (- 320 80) :y -20 :baseline 240 :parallax 3.2)
(assoc (texture "dream/pedestals.png") :x 0 :y 0 :baseline 139)]
:entities {:clouds (assoc (particle-effect "dream/cloudy2") :x 160 :y 120 :baseline 241)
:sword (assoc (texture "dream/sword.png")
:x 144 :y 122 :baseline 139
:script (actions/get-script entities
(actions/walk-to entities :ego [168 76] :face :left)
(actions/do-dialogue entities :ego "Awesome! I'll take this sword and become a knight.")
(actions/stop-walking entities :ego :face :right)
(actions/do-dialogue entities
:fairy-godfather "Tick, I'm not sure that being a knight is right for you."
:fairy-godfather "I think you'd be better suited for a more menial job."
:ego "Hey! Why can't I be a knight! It's my destiny!"
:ego "And plus, knights get all the chicks!"
:ego "And this plaque here says that chicks dig knights.")))
:broom (assoc (texture "dream/broom.png") :x 286 :y 122
:path (catmull-rom-spline (map #(apply vector-2* %) [[286 122] [286 128]]) true)
:update-fn (partial utils/update-path-location 0.30)
:baseline 240
:script (actions/get-script entities
(actions/walk-to entities :ego [267 70] :face :right)
(actions/talk entities :ego "So do I kill ghouls with this broom?")
(actions/stop-walking entities :ego :face :left)
(actions/do-dialogue entities :fairy-godfather "Not quite, young Tick."
:fairy-godfather "This weapon is used to fight a more persistent foe."
:fairy-godfather "Dust and grime!"
:fairy-godfather "Take the broom, and cast it into the pit of fate."
:fairy-godfather "Then you can fulfill your fate as a janitor.")))
:shovel (assoc (texture "dream/shovel.png") :x 33 :y 122
:path (catmull-rom-spline (map #(apply vector-2* %) [[22 122] [22 128]]) true)
:update-fn (partial utils/update-path-location 0.33)
:baseline 240
:script (actions/get-script entities
(actions/walk-to entities :ego [61 72] :face :left)
(actions/talk entities :ego "A shovel?")
(actions/stop-walking entities :ego :face :right)
(actions/do-dialogue entities :fairy-godfather "That's right, young Tick!"
:fairy-godfather "A grave-digger is a noble profession!"
:fairy-godfather "Take the shovel, and cast it into the pit of fate.")))
:sign (assoc (texture "dream/sign.png") :x 229 :y 33 :baseline 207)
:fairy-godfather (assoc (animation->texture screen fairy-godfather-anim)
:x 200 :y 130
:baseline 150
:talk fairy-godfather-talk-anim
:stand fairy-godfather-anim
:anim fairy-godfather-anim :anim-start 0
:path (catmull-rom-spline (map #(apply vector-2* %) [[200 130] [200 134]]) true)
:update-fn (partial utils/update-path-location 0.2)
:script (actions/get-script entities (actions/do-dialogue entities :fairy-godfather "Young Tick, you must choose your destiny!")))}
:collision "dream/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 40 0.5 1.6)
:start-pos [140 55])))