194 lines
17 KiB
Clojure
194 lines
17 KiB
Clojure
(ns advent.screens.rooms.inside-cafeteria
|
|
(:require [advent.screens.rooms :as rooms]
|
|
[advent.screens.items :as items]
|
|
[advent.actions :as actions]
|
|
[advent.utils :as utils]
|
|
[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-fight-entity []
|
|
(assoc (texture "inside-cafeteria/fight.png")
|
|
:x 0
|
|
:y 0
|
|
:baseline 1000))
|
|
|
|
(defn play-battle [entities anim]
|
|
(actions/transition-music entities :town-1 :fight)
|
|
(actions/add-entity entities :fight (get-in @entities [:room :fight]))
|
|
(actions/add-entity entities :hands-fight (get-in @entities [:room :hands-fight]))
|
|
(actions/play-animation entities :hands-fight anim)
|
|
(actions/transition-music entities :fight :town-1)
|
|
(actions/remove-entity entities :hands-fight)
|
|
(actions/remove-entity entities :fight))
|
|
|
|
(defn do-warrior-dialogue [entities]
|
|
(actions/walk-to entities :ego [150 45] :face :left)
|
|
(actions/talk entities :ego "Hey guys!")
|
|
(actions/talk entities :warriors "Hark! Good day, young esquire.")
|
|
(actions/present-choices entities
|
|
{:choices ["Why dost thou speaketh in this manner?"
|
|
{:run #(actions/respond entities %
|
|
:warriors "`Tis a tradition!"
|
|
:warriors "All knights speaketh in such a manner."
|
|
:warriors "As my father instructedeth unto me as a mere lad: "
|
|
:warriors "'Son, thou must speaketh in this manner.'"
|
|
:warriors "And I asketh unto him:"
|
|
:warriors "'But father, why musteth I speaketh in this manner?'"
|
|
:warriors "'Yea, my son, for thou art a knight. And thou musteth speaketh in this manner.'"
|
|
:warriors "And I toldeth unto him:"
|
|
:warriors "'Thou art my father, and I am thy son. Therefore I will speaketh in this manner.'"
|
|
:ego "... I think I've got the idea.")
|
|
:choices actions/previous-choices}
|
|
(when (not (actions/has-obtained? entities :medal))
|
|
"Can I be a knight like you guys?")
|
|
{:run #(actions/respond entities %
|
|
:warriors "We thinketh not, young esquire."
|
|
:warriors "You lacketh the strength and vigor required for such a task.")
|
|
:choices ["But I'm on a quest to become a knight!"
|
|
{:run #(actions/respond entities %
|
|
:warriors "Young esquire, thou art valiant in heart. "
|
|
:warriors "Departeth henceforth and go hitherto, unto the gym.")}
|
|
"I challenge you to a arm wrestling match to prove my strength."
|
|
{:run (fn [msg]
|
|
(actions/respond entities msg :warriors "Prepare thyself, thy task is not for the faint of heart.")
|
|
(if (actions/has-item? @entities :flask-1-strength)
|
|
(do
|
|
(actions/do-dialogue entities :ego "One sec.")
|
|
(sound! (sound "ego/potion.ogg") :play)
|
|
(actions/play-animation entities :ego :grow :stop? false)
|
|
(play-battle entities :win)
|
|
(actions/do-dialogue entities
|
|
:warriors "Congratulations young master. Thou art worthy in might."
|
|
:warriors "Take my medal of strength.")
|
|
(actions/give entities :medal))
|
|
(do
|
|
(play-battle entities :lose)
|
|
(actions/do-dialogue entities
|
|
:warriors "You lost, young master. Go hitherto, unto thy gym."))))}
|
|
"Something else."
|
|
{:choices actions/something-else}]
|
|
}
|
|
"Goodbye."
|
|
{:run #(actions/respond entities % :warriors "Fare thee well, and godspeed.")}]}))
|
|
|
|
(defn do-ladder-guard-dialogue [entities]
|
|
(actions/walk-to entities :ego [170 45] :face :right)
|
|
(actions/do-dialogue entities
|
|
:ego "Hello."
|
|
:ladder-guard "'Ello, young sire.")
|
|
(actions/present-choices entities {:choices [(when (not (actions/has-obtained? entities :ladder))
|
|
"Nice ladder.")
|
|
{:run #(actions/respond entities %
|
|
:ladder-guard "Tis nice, indeed!"
|
|
:ladder-guard "Belongeth to the Duke of Remington, it doth.")
|
|
:choices ["Can I have it?"
|
|
{:run #(actions/respond entities % :ladder-guard "No.")
|
|
:choices ["Please?"
|
|
{:run #(actions/respond entities %
|
|
:ladder-guard "No.")
|
|
:choices ["Pretty please?"
|
|
{:run #(actions/respond entities %
|
|
:ladder-guard "No.")
|
|
:choices ["Pretty pretty please?"
|
|
{:run #(actions/respond entities %
|
|
:ladder-guard "No.")
|
|
:choices ["Pretty pretty pretty please?"
|
|
{:run #(do (actions/respond entities %
|
|
:ladder-guard "Well, okay."
|
|
:ladder-guard "Do not darest telleth a soul, or thou wilst bring my family dishonor!"
|
|
:ladder-guard "I will shame the name of my father, Luke, and his father, Puke."
|
|
:ladder-guard "Not to mention, the duke will have my head!")
|
|
(actions/walk-to entities :ego [245 75] :face :right)
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/remove-entity entities :ladder)
|
|
(actions/give entities :ladder))}
|
|
"Nevermind."
|
|
{:run #(actions/respond entities %)}]}
|
|
"Nevermind."
|
|
{:run #(actions/respond entities %)}]}
|
|
"Nevermind."
|
|
{:run #(actions/respond entities %)}]}
|
|
"Nevermind."
|
|
{:run #(actions/respond entities %)}]}
|
|
"Something else."
|
|
{:choices actions/something-else}]}
|
|
"Why aren't you sitting and eating?"
|
|
{:run #(do (actions/respond entities % :ladder-guard "I'm on duty, young sire.")
|
|
(when (not (actions/has-obtained? :ladder))
|
|
(actions/do-dialogue entities
|
|
:ladder-guard "Dost thou seeth this ladder?"
|
|
:ladder-guard "Tis my duty to guardeth it."
|
|
:ladder-guard "Why, if I didst sit and dineth with my friends, a hoodlum wouldst steal it.")))
|
|
:choices actions/previous-choices}
|
|
"What's your name?"
|
|
{:run #(actions/respond entities % :ladder-guard "I am Took, son of Luke, son of Puke.")
|
|
:choices actions/previous-choices}
|
|
"Goodbye."
|
|
{:run #(actions/respond entities % "Goodbye.")}]})
|
|
)
|
|
|
|
(defn make [screen]
|
|
(let [warriors-stand-sheet (texture! (texture "inside-cafeteria/warriors-stand.png") :split 66 126)
|
|
warriors-stand (animation 0.2 (for [i [0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 2 2 2 2 3 3 3 0 0 0 2 2 2 ]]
|
|
(aget warriors-stand-sheet 0 i)))
|
|
ladder-guard-sheet (texture! (texture "inside-cafeteria/ladder-guard.png") :split 37 87)
|
|
ladder-guard-stand (animation 0.1 [(aget ladder-guard-sheet 0 0)])
|
|
ladder-guard-talk (animation 0.2 (for [i [0 0 0 0 1 0 0 1]]
|
|
(aget ladder-guard-sheet 0 i)))
|
|
base-fight (repeat 3 [0 1 0 4 0 1 0 4 0 1 0 4 0 1 0 4 0 1 0 4 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 1 0 0 0 4 0 1 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 1 1 1 0 0 0 1 1 2 2 2 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 1 0 4 0 1 0 4 0 4 0 4 0 4 0 4 4 4 4 4 4 5 5 5 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0 ])
|
|
hands-fight-win (utils/make-anim "inside-cafeteria/hands-fight.png" [104 104] 0.075 (flatten (concat
|
|
base-fight
|
|
[1 1 1 1 1 0 1 0 1 2 2 1 1 2 2 1 1 2 2 2 1 1 0 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3])))
|
|
hands-fight-lose (utils/make-anim "inside-cafeteria/hands-fight.png" [104 104] 0.075 (flatten (concat
|
|
base-fight
|
|
[4 4 4 4 4 4 0 0 0 0 4 4 4 0 0 0 4 4 4 0 0 1 1 0 0 4 4 4 5 5 5 5 4 4 4 5 5 5 5 4 4 4 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6])))]
|
|
(rooms/make :music :town-1
|
|
:interactions
|
|
{:right-dir {:box [300 0 320 120]
|
|
:script (actions/get-script
|
|
entities
|
|
(actions/walk-to entities :ego [319 50])
|
|
(actions/transition-background entities :inside-castle [65 150])
|
|
(actions/walk-to entities :ego [126 80]))
|
|
:cursor :right}
|
|
}
|
|
:layers [(assoc (texture "inside-cafeteria/background.png") :x 0 :y 0 :baseline 0)]
|
|
:entities {
|
|
:warriors (actions/start-animation screen (assoc (animation->texture screen warriors-stand) :x 5 :y 9 :baseline 180
|
|
|
|
:left {:stand (utils/flip warriors-stand)
|
|
:talk (utils/flip warriors-stand)}
|
|
:right {:stand warriors-stand
|
|
:talk warriors-stand}
|
|
:facing :right
|
|
:script (actions/get-script entities
|
|
(do-warrior-dialogue entities)
|
|
))
|
|
:stand)
|
|
:ladder-guard (actions/start-animation screen (assoc (animation->texture screen ladder-guard-stand) :x 202 :y 85 :baseline 155
|
|
:stand ladder-guard-stand
|
|
:talk ladder-guard-talk
|
|
:script (actions/get-script entities (do-ladder-guard-dialogue entities)))
|
|
:stand)
|
|
:ladder (assoc (texture "inside-cafeteria/ladder.png") :x 250 :y 85 :baseline 155
|
|
:script (actions/get-script entities
|
|
(actions/talk entities :ladder-guard "Do not toucheth, young sire.")))}
|
|
:collision "inside-cafeteria/collision.png"
|
|
:fight (make-fight-entity)
|
|
:hands-fight (assoc (animation->texture screen hands-fight-win)
|
|
:x 122
|
|
:y 38
|
|
:baseline 1001
|
|
:win hands-fight-win
|
|
:lose hands-fight-lose)
|
|
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.50)
|
|
:apply-state (fn [entities]
|
|
(as-> entities entities
|
|
(if (actions/has-item? entities :ladder)
|
|
(update-in entities [:room :entities] #(dissoc % :ladder))
|
|
entities)))
|
|
:start-pos [300 55])))
|