(ns advent.screens.rooms.cat-tree (:require [advent.screens.rooms :as rooms] [advent.actions :as actions] [advent.screens.items :as items] [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 get-down [entities] (actions/walk-straight-to entities :ego [151 50] :update-baseline? false :face :left) (actions/play-animation entities :ego :reach) (actions/remove-entity entities :blank) (actions/remove-entity entities :ladder) (actions/give entities :ladder)) (defn do-saved-grandma-dialogue [entities] (actions/walk-to entities :ego [165 45] :face :left) (actions/do-dialogue entities :grandma "Oh it's my handsome hero again!" :grandma "Back for another kiss?" :ego "Umm, erm...") (actions/play-animation entities :ego :get-sick :stop? false) (actions/walk-straight-to entities :ego [205 10]) (actions/talk entities :ego "No way.")) (defn do-grandma-dialogue-with-cat [entities] (actions/walk-to entities :ego [165 45] :face :left) (actions/do-dialogue entities :grandma "Oh, good, a strapping young lad!" :grandma "Are you here to help this damsel in distress?") (actions/present-choices entities {:choices ["Damsel in distress?" {:run #(actions/respond entities % :grandma "Yes! I'm a damsel, and I'm in distress!" :ego "Don't you have to be young to be a damsel?" :grandma "I'm 113 years young! I'm practically a baby!") :choices ["What's your distress?" {:run #(actions/respond entities % :grandma "It's my Smuffle Wuffles!" :grandma "We were on a pleasant walk through the woods." :grandma "Then we got in argument, and so he ran up into that tree!" :ego "An argument? With a cat?" :grandma "Yes of course! We were arguing about politics!") :choices ["So you want me to get your cat down?" {:run #(actions/respond entities % :grandma "Yes! I need a courageous hero to rescue Smuffle Wuffles for me." :grandma "And this damsel in distress will reward you handsomely for your bravery.") :choices actions/previous-choices} "Cat's can't talk. How could he argue about politics?" {:run #(actions/respond entities % :grandma "Smuffle Wuffles is not your ordinary cat." :grandma "He's got an exceptionally high intellect for a cat." :ego "So other people can hear him?" :grandma "Well, not exactly." :grandma "No one else gives him the time of day, so he only speaks when we're alone." :ego "Why would such an intelligent cat be named Smuffle Wuffles?" :grandma "You'd have to take that up with his parents, Mr. and Mrs. Cuddly Wuddly.") :choices actions/previous-choices} "Something else." {:choices actions/something-else}]} "113 years old isn't young, lady." {:run #(actions/respond entities % :grandma "Oh sure it is!" :grandma "I do the same things every young damsel does." :grandma "Sit in my rocking chair, knit, take photos of the grandkids..." :ego "... Right.") :choices actions/previous-choices} "Something else." {:choices actions/something-else}]} "What are you doing way out here?" {:run #(actions/respond entities % :grandma "Me and my cat, Smuffle Wuffles were on a nice, leisurely stroll." :grandma "Then he ran up that tree!" :grandma "So I've been camped out here for the last two days.") :choices actions/previous-choices} "Do you know how I can pull the Sword of Blergh, and become a knight?" {:run #(actions/respond entities % :grandma "Young man, I was here when that sword was put in the stone 100 years ago!" :grandma "Of course I know how it can be pulled!" :grandma "One must prove themselves worthy in wisdom, courage, and might." :grandma "How about proving your courage by helping rescue Smuffle Wuffles?") :choices actions/previous-choices} "Later." {:run #(actions/respond entities % :grandma "Please come back soon and help me rescue Smuffle Wuffles!")}]})) (defn do-grandma-dialogue [entities] (if (actions/has-obtained? entities :kiss) (do-saved-grandma-dialogue entities) (do-grandma-dialogue-with-cat entities))) (defn make [screen] (let [cat-stand-sheet (texture! (texture "cat-tree/cat-stand.png") :split 22 10) cat-stand (animation 0.15 (for [i (flatten [(repeat 10 0) 1 1 (repeat 10 0) 2 3 4 3 0 0 2 3 4 3 (repeat 10 0) 1 1 (repeat 10 0) 5 5 6 6 7 (repeat 10 [7 8]) 6 5 0])] (aget cat-stand-sheet 0 i))) cat-walk (animation 0.2 [(texture "cat-tree/pounce.png")]) ladder-entity (assoc (texture "inside-cafeteria/ladder.png") :x 120 :y 60 :baseline 162) grandma-stand (utils/make-anim "cat-tree/grandma.png" [25 36] 0.2 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) grandma-squat-1 (utils/make-anim "cat-tree/grandma.png" [25 36] 0.2 [3 4 5 5 5 5 5]) grandma-squat-2 (utils/make-anim "cat-tree/grandma.png" [25 36] 0.2 [5 5 4 3]) grandma-talk (utils/make-anim "cat-tree/grandma.png" [25 36] 0.2 [0 2 0 2 0 2 0 2 0 2 0 1 0 2 0 0]) grandma-kiss (utils/make-anim "cat-tree/grandma.png" [25 36] 0.2 [0 8 9 10 9 10 9 10 9 8 0])] (rooms/make :music :town-2 :interactions {:down-dir {:box [150 0 270 20] :script (actions/get-script entities (actions/walk-to entities :ego [203 1]) (actions/transition-background entities :outside-house [137 204]) (actions/walk-to entities :ego [195 140])) :cursor :down} :ladder-area {:box [134 40 265 190] :scripts {:ladder (actions/get-unsaved-script entities (actions/talk entities :ego "I'll just set this up.") (actions/walk-to entities :ego [151 50] :face :left) (actions/play-animation entities :ego :reach) (actions/remove-item entities :ladder) (actions/add-entity entities :ladder ladder-entity) (actions/walk-straight-to entities :ego [140 85] :face :right :update-baseline? false) (actions/add-entity entities :blank (rooms/make-entity :blank {:object nil :x 0 :y 0 :width 320 :height 240 :baseline 240 :script (actions/get-script entities (when (get-in @entities [:room :entities :ladder]) (actions/talk entities :ego "I'll get down.") (get-down entities)))})) )}} :grass {:box [26 105 60 160] :script (actions/get-script entities (if (not (actions/has-item? entities :grass)) (do (actions/walk-to entities :ego [60 100] :face :left) (actions/play-animation entities :ego :reach) (actions/give entities :grass)) (actions/talk entities :ego "I don't really need any more grass.")))} :grandma {:box [109 33 132 98] :script (actions/get-script entities (do-grandma-dialogue entities)) }} :layers [(assoc (texture "cat-tree/background.png") :x 0 :y 0 :baseline 0) (assoc (texture "cat-tree/tree-and-rock.png") :x 0 :y 0 :baseline 161) (assoc (texture "cat-tree/sillhoute.png") :x 0 :y 0 :baseline 240)] :entities {:cat (actions/start-animation screen (assoc (animation->texture screen cat-stand) :x 184 :y 173 :baseline 1000 :walk cat-walk :stand cat-stand :script (actions/get-script entities (actions/talk entities :ego "Here kitty, kitty, kitty.") (actions/talk entities :ego "Kitty's not so interested in me.")) :scripts {:cat-toy (actions/get-script entities (actions/play-animation entities :ego :cat-toy) (if (get-in @entities [:room :entities :ladder]) (do (actions/talk entities :ego "I think he's going for it!") (actions/play-animation entities :ego :cat-toy-first-half :stop? false) (sound! (sound "cat-tree/cat.ogg") :play) (actions/walk-straight-to entities :cat [138 40] :update-baseline? false :speed 3) (actions/play-animation entities :ego :cat-toy-last-half) (actions/play-animation entities :grandma :squat-1 :stop? false) (actions/remove-entity entities :cat) (actions/play-animation entities :grandma :squat-2) (actions/do-dialogue entities :grandma "Thank you for rescuing my furry friend, young man!") (get-down entities) (actions/walk-straight-to entities :ego [165 45] :face :left) (actions/do-dialogue entities :ego "It's no big deal." :grandma "You won't go unrewarded!" :grandma "Come here young man.") (actions/walk-straight-to entities :ego [133 35]) (actions/talk entities :grandma "For your impressive display of courage and bravery, I give you this. ") (sound! (sound "cat-tree/kiss.ogg") :play) (actions/play-animation entities :grandma :kiss) (actions/play-animation entities :ego :get-sick :stop? false) (actions/walk-straight-to entities :ego [165 45]) (actions/do-dialogue entities :ego "Ugh! Gross!" :ego "What's this?") (actions/give entities :kiss) (actions/do-dialogue entities :ego "A kiss for an inventory item?" :ego "Sounds like the game designer was running out of good ideas.")) (actions/talk entities :ego "I guess I'm too far away.")))}) cat-stand) :grandma (assoc (animation->texture screen grandma-stand) :x 130 :y 37 :baseline 200 :anim grandma-stand :anim-start 0 :talk grandma-talk :kiss grandma-kiss :stand grandma-stand :squat-1 grandma-squat-1 :squat-2 grandma-squat-2 :origin-x 12 :origin-y 0 :scale-x 1.45 :scale-y 1.45)} :collision "cat-tree/collision.png" :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.20) :apply-state (fn [entities] (as-> entities entities (if (actions/has-item? entities :kiss) (update-in entities [:room :entities] #(dissoc % :cat)) entities))) :start-pos [203 1])))