This commit is contained in:
2014-11-10 13:33:58 -08:00
28 changed files with 300 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
</array>
</plist>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -12,7 +12,7 @@
[advent.utils :as utils]
[clojure.core.async :refer [put! <! <!! >! >!! chan go thread take! alts!!]])
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.graphics.g2d TextureRegion Animation]
[com.badlogic.gdx Screen]))
(defprotocol IAction
@@ -42,10 +42,10 @@
entity)))
(defn find-animation [entity anim]
(if (keyword? anim)
(if (instance? Animation anim)
anim
(or (get-in entity [(:facing entity) anim])
(anim entity))
anim))
(get entity anim))))
(defn start-animation [screen entity anim]
(let [new-anim (find-animation entity anim)]

View File

@@ -48,5 +48,7 @@
(def balloon {:name "Choicest of balloons" :value :balloon :cursor :balloon})
(def frog-legs {:name "Frog legs" :value :frog-legs :cursor :frog-legs})
(def stool {:name "Stool" :value :stool :cursor :stool})
(def teddy {:name "Teddy Bear" :value :teddy :cursor :teddy})
(def portrait {:name "Portrait" :value :portrait :cursor :portrait})

View File

@@ -10,17 +10,135 @@
[play-clj.g2d :refer :all]))
(defn do-antique-dialogue [entities]
(actions/do-dialogue entities
:shopkeep "Welcome to my antique shop!"
:shopkeep "Can I help you?")
(actions/present-choices entities
{:choices ["What do you have for sale here?"
{:run #(actions/respond entities %
:shopkeep "For sale?"
:shopkeep "This is a very UNIQUE antique shop."
:shopkeep "Nothing's for sale, sonny."
:shopkeep "It's more like a museum."
:shopkeep "You can take look around at some of my items, but nothing is for sale.")
:choices ["How do you make money then?"
{:run #(actions/respond entities %
:shopkeep "Mostly insurance claims."
:shopkeep "When you run such an impressive shop as I do, items sometimes just go missing.")
:choices actions/previous-choices}
"Is there anything here you will sell?"
{:run #(actions/respond entities %
:shopkeep "No."
:shopkeep "But I do have some free magical fire mints that Gandarf brewed up."
:shopkeep "Careful! They're spicy.")
:choices actions/previous-choices}
"So in order to continue on my quest, I'll need to solve some puzzle here?"
{:run #(actions/respond entities %
:shopkeep "I have no idea what you're talking about, sonny.")
:choices actions/previous-choices}
"Something else"
{:choices actions/something-else}]}
(when (get-in @entities [:state :wants-toy])
"Listen, I really need that teddy bear you have.")
{:run #(actions/respond entities %
:shopkeep "Why?"
:shopkeep "It belonged to my long lost son."
:shopkeep "Why should I give it to you?")
:choices ["I just need it ok?"
{:run #(actions/respond entities %
:shopkeep "I'm sorry, it's not for sale.")
:choices actions/something-else}
"Your long lost son said I could have it."
{:run #(do (actions/respond entities %
:shopkeep "REALLY? You've met him?"
:ego "... erm. Yes!"
:shopkeep "If you really met him, you'll have to prove it."
:shopkeep "What is my son's name?"))
:choices ["... Bud?"
{:run #(actions/respond entities % :shopkeep "No. *sigh* That's not it.")}
"... Steve?"
{:run #(actions/respond entities % :shopkeep "No. *sigh* That's not it.")}
"... Bob?"
{:run #(actions/respond entities % :shopkeep "No. *sigh* That's not it.")}
(when ((get-in @entities [:state :clues]) :name)
"Herb.")
{:run #(do (actions/respond entities %
:shopkeep "Yes, that's it!"
:shopkeep "You must have really met my son!"
:shopkeep "Of course you can keep the teddy bear.")
(actions/give entities items/teddy))}]}]}
"How's life in the antique shop biz?"
{:run #(actions/respond entities %
:shopkeep "Pretty lonely."
:shopkeep "My long lost son used to help me run this shop, but he's been gone for five years now."
:shopkeep "I've been couped up in here by myself ever since."
:shopkeep "Now all I have is this grandfather clock to keep me company.")
:choices actions/previous-choices}
"Nevermind." {:run #(actions/respond entities % :shopkeep "Feel free to look around.")}]}))
(defn make [screen]
(rooms/make :music :inside-antique
:interactions
{:down {:box [60 0 290 25]
:cursor :down
:script (actions/get-script entities
(actions/walk-to entities :ego [222 3])
(actions/transition-background entities :inside-castle [182 90]))}}
:layers [(assoc (texture "inside-antique/background.png") :x 0 :y 0 :baseline 0)]
:entities {}
:collision "inside-antique/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.50)))
(let [shopkeep-sheet (texture! (texture "inside-antique/shopkeep-talk.png") :split 18 21)
shopkeep-stand (animation 0.1 (for [i (flatten [(repeat 30 0) 1 (repeat 50 0) 1 0 1 0 1])]
(aget shopkeep-sheet 0 i)))
shopkeep-talk (animation 0.15 (for [i [0 2 0 2 0 3 1 0]]
(aget shopkeep-sheet 0 i)))]
(rooms/make :music :inside-antique
:interactions
{:down {:box [60 0 290 25]
:cursor :down
:script (actions/get-script entities
(when ((set (get-in @entities [:state :inventory])) items/portrait)
(actions/walk-to entities :ego [222 3])
(actions/talk entities :shopkeep "Excuse me sonny. Please return my belongings before you leave.")
(actions/walk-to entities :ego [136 80] :face :left)
(actions/play-animation entities :ego :reach)
(actions/remove-item entities items/portrait))
(actions/walk-to entities :ego [222 3])
(actions/transition-background entities :inside-castle [182 90]))}
:window {:box [212 130 256 180]
:script (actions/get-script entities
(actions/talk entities :ego "It's a nice, big window."))
:scripts {:portrait (actions/get-script entities
(actions/walk-to entities :ego [151 60] :face :right)
(actions/play-animation entities :ego :reach)
(actions/talk entities :ego "The portrait says 'Herb' on the back.")
(actions/update-state entities (fn [state] (update-in state [:clues] #(conj % :name)) )))}}}
:layers [(assoc (texture "inside-antique/background.png") :x 0 :y 0 :baseline 0)]
:entities {:shopkeep (actions/start-animation screen (assoc (animation->texture screen shopkeep-stand) :x 137 :y 128 :baseline 112
:stand shopkeep-stand
:talk shopkeep-talk
:script (actions/get-script entities (do-antique-dialogue entities))
)
:stand)
:portrait (assoc (texture "inside-antique/portrait.png")
:x 109
:y 120
:script (actions/get-script entities
(actions/walk-to entities :ego [136 80] :face :left)
(actions/play-animation entities :ego :reach)
(actions/talk entities :ego "It's a portrait. There's something on the back but I can't read it.")
(actions/remove-entity entities :portrait)
(actions/give entities items/portrait)))
:bowl (assoc (texture "inside-antique/bowl.png")
:x 155
:y 125
:baseline 125
:script (actions/get-script entities
(if (= 3 (get-in @entities [:state :mints-eaten]))
(do (actions/walk-to entities :ego [145 80] :face :right)
(actions/do-dialogue entities
:ego "She's all out."
:ego "Maybe Gandarf can brew her up another batch."))
(do (actions/walk-to entities :ego [145 80] :face :right)
(actions/talk entities :ego "I'll just try one of these mints.")
(actions/play-animation entities :ego :reach)
(actions/update-state entities (fn [s] (assoc s :mints-eaten (inc (s :mints-eaten)))))
(actions/play-animation entities :ego [:fire (get-in @entities [:state :mints-eaten])])
(actions/talk entities :ego "WOWZA! Those are hot.")
(when (= 3 (get-in @entities [:state :mints-eaten]))
(actions/talk entities :shopkeep "You brat! You ate the last mint.")
(actions/talk entities :shopkeep "Since you ate the last one, you have to go tell Gandarf to bring me some more."))))))}
:collision "inside-antique/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.50))))

View File

@@ -9,12 +9,28 @@
[play-clj.utils :refer :all]
[play-clj.g2d :refer :all]))
(defn do-wizard-dialogue [entities]
(actions/do-dialogue entities :wizard "What can I do for you boy?")
(actions/present-choices entities
{:choices [(when (= 3 (get-in @entities [:state :mints-eaten]))
"The antique shopkeeper needs more fire mints.")
{:run #(do (actions/respond entities %
:wizard "Already?"
:wizard "Ok, I'll deliver them myself. Don't touch anything while I'm gone.")
(actions/update-state entities (fn [s] (assoc s :mints-eaten 0)))
(actions/remove-entity entities :wizard))}
"Goodbye, Gandarf."
{:run #(actions/respond entities % :wizard "Goodbye, boy.")}]}))
(defn make [screen]
(let [wizard-sheet (texture! (texture "wizard/talk.png") :split 20 46)
wizard-stand (animation 0.2 (for [i (flatten [(repeat 10 0) 1])]
(aget wizard-sheet 0 i)))
wizard-talk (animation 0.2 (for [i [0 2 0 2 1 2 0 3 0 2 0 1 0 2]]
(aget wizard-sheet 0 i)))]
(aget wizard-sheet 0 i)))
safelock-sheet (texture! (texture "inside-house/safe-lock.png") :split 9 2)
safe-lock (animation 0.1 (for [i (flatten [(repeat 20 0) 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 (range 3 20) 20 20 20 20 21 21 21 21 21 20 20 21 21 21 21 21 20 20 20 ])]
(aget safelock-sheet 0 i)))]
(rooms/make :music :inside-fangald
:interactions {:down-dir {:box [151 0 320 20]
:script (actions/get-script entities
@@ -24,19 +40,26 @@
:safe {:box [34 70 70 115]
:script (actions/get-script entities
(actions/walk-to entities :ego [59 65])
(actions/play-animation entities :ego :squat)
(actions/give entities items/frog-legs)
(actions/talk entities :ego "I found some frog legs inside."))}
(if (get-in @entities [:room :entities :wizard])
(actions/talk entities :wizard "Don't touch my MagiSafe!!")
(do
(actions/play-animation entities :ego :squat)
(actions/give entities items/frog-legs)
(actions/talk entities :ego "I found some frog legs inside."))))}
}
:layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "inside-house/desk.png") :x 0 :y 0 :baseline 200)
(assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)]
:entities {:wizard (actions/start-animation screen (assoc (animation->texture (doto screen) wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75
:entities {:wizard (actions/start-animation screen (assoc (animation->texture screen wizard-stand) :x 228 :y 80 :baseline 160 :scale-x 1.75 :scale-y 1.75
:left {:talk (utils/flip wizard-talk)
:stand (utils/flip wizard-stand)}
:right {:talk wizard-talk
:stand wizard-stand}
:facing :left)
:facing :left
:script (actions/get-script entities (do-wizard-dialogue entities)))
:stand)
:safe-lock (actions/start-animation screen (assoc (animation->texture screen safe-lock) :x 51 :y 95 :baseline 145
:stand safe-lock)
:stand)
:flask (assoc (texture "inside-house/flask.png")
:x 265 :y 80 :baseline 240

View File

@@ -44,7 +44,8 @@
:peddler {:box [110 90 128 146]
:script (actions/get-script
entities
(actions/walk-to entities :ego [191 90])
(actions/walk-to entities :ego [191 90] :face :left)
(actions/do-dialogue entities
:ego "Hello there, peddler."
:peddler "Good day sir! Care to see any of my wares?"
@@ -52,14 +53,66 @@
:ego "What 'wares' are you selling?"
:peddler "I have the choicest of all types of wares..."
:peddler "...I'm well stocked on used earplugs..."
:peddler "...glass eyes, motivational tapes... "
:peddler "... and this nice, big, red balloon."
:ego "I sure am interested in that balloon."
:peddler "An excellent selection! It is the choicest of balloons you'll ever find."
:peddler "This bundle of joy will only set you back 75 sheckels."
:ego "But I haven't got any money!"
:peddler "Then you won't have the choicest of balloons.")
(actions/give entities items/balloon))}}
:peddler "...glass eyes..."
:peddler "... and motivational tapes."
:peddler "And today, I have a one day special!"
:peddler "Every purchase comes with a free balloon!")
(actions/present-choices entities {:choices ["I'm interested in your earplugs."
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true)))
(actions/respond entities %
:peddler "A choice choice sir!"
:peddler "These earplugs have been used by the the choicest of wearers."
:peddler "I can see a young man like yourself enjoying these choice earplugs for ages to come!"
:peddler "And remember, every purchase comes with the choicest of balloons!"
:peddler "That'll just be 10 sheckels."
:ego "But I haven't got any money!"
:peddler "Well I'm afraid you won't have the choicest of earplugs."
:ego "Can't I give you something else for them?"
:peddler "Well, I am low on choice children's toys."
:peddler "If you can bring me one, and I mean the choicest of toys, I will give you the earplugs."))
:choices actions/previous-choices}
"I'm interested in a glass eye."
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true)))
(actions/respond entities %
:peddler "The choicest choice, young man!"
:peddler "This glass eye is made out of the choicest glass, from across the sea."
:peddler "And remember, every purchase comes with the choicest of balloons!"
:peddler "That'll just be 95 sheckels."
:ego "But I haven't got any money!"
:peddler "Well I'm afraid you won't have the choicest of glass eyes."
:ego "Can't I give you something else for them?"
:peddler "I'll tell you what, I don't have any thing for the kids that come to my stand."
:peddler "If you can bring me the choicest of toys, I will give you the glass eye."))
:choices actions/previous-choices}
"I'm interested in the motivational tapes."
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true)))
(actions/respond entities %
:peddler "Sure thing!"
:peddler "Has your luck got you down? Feeling pathetic?"
:peddler "These choicest of motivation tapes will convince you that life isn't so bad."
:peddler "For only 3 easy payments of 29.99 scheckles, they're yours!"
:ego "But I'm broke!"
:peddler "Well I'm afraid you won't have the choicest of glass eyes."
:ego "Is there anything else you'd take instead?"
:peddler "If you can bring me a nice kid's toy, I will give you the tapes."))
:choices actions/previous-choices}
"Nevermind." {:run #(actions/respond entities % :peddler "Goodbye, sir.")}]}))
:scripts {:teddy (actions/get-script entities
(actions/remove-item entities items/teddy)
(actions/do-dialogue entities
:peddler "That is the choicest of teddy bears!"
:peddler "True to my word, I will give you one of my wares."
:peddler "What would you like?")
(actions/present-choices entities
{:choices ["The glass eye."
{:run #(do (actions/respond entities % :peddler "Of course sir. Here you go."))}
"The motivational tapes."
{:run #(do (actions/respond entities % :peddler "Of course sir. Here you go."))}
"The used earplugs."
{:run #(do (actions/respond entities % :peddler "Of course sir. Here you go."))}]})
(actions/talk entities :peddler "And, of course, here is your balloon.")
(actions/give entities items/balloon)
(actions/talk entities :peddler "Thank you for your business!"))}}}
:layers [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)]
:entities {:peddler (actions/start-animation screen
(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil

View File

@@ -83,6 +83,7 @@
squat-sheet (texture! (texture "ego/squat.png") :split 18 36)
reach-sheet (texture! (texture "ego/reach.png") :split 18 36)
cat-toy-sheet (texture! (texture "ego/cat-toy.png") :split 41 50)
fire-sheet (texture! (texture "ego/fire.png") :split 18 36)
walk-right (animation 0.075 (for [i (range 8)]
(texture (aget player-sheet 0 i))))
stand-anim (animation 0.1 (for [i (flatten [(repeat 6 [(repeat 10 0) (repeat 3 1) (repeat 20 0)]) 3 4 5 5 5 6 5 6 5 6 5 4 3 ])]
@@ -94,19 +95,31 @@
reach-anim (animation 0.1 (for [i [0 1 2 3 3 3 3 3 3 2 1 0]]
(texture (aget reach-sheet 0 i))))
cat-toy-anim (animation 0.1 (for [i [0 0 1 1 2 2 3 4 3 2 3 4 3 2 3 4 3 2 3 4 3 2 2 1 1 0 0]]
(texture (aget cat-toy-sheet 0 i))))
(texture (aget cat-toy-sheet 0 i))))
fire-1-anim (animation 0.1 (for [i [0 1 2 2 2 3 2 3 2 2 2 1 0]]
(texture (aget fire-sheet 0 i))))
fire-2-anim (animation 0.1 (for [i [0 1 2 2 2 2 3 2 3 2 2 2 4 5 6 7 2 2 2 2 2 2 2 2 1 0]]
(texture (aget fire-sheet 0 i))))
fire-3-anim (animation 0.1 (for [i [0 1 2 2 2 2 3 2 3 2 2 2 4 5 6 7 2 2 2 8 9 10 11 2 2 2 2 2 2 2 2 0]]
(texture (aget fire-sheet 0 i))))
ego {:right {:walk walk-right
:stand stand-anim
:talk talk-anim
:squat squat-anim
:reach reach-anim
:cat-toy cat-toy-anim}
:cat-toy cat-toy-anim
[:fire 1] fire-1-anim
[:fire 2] fire-2-anim
[:fire 3] fire-3-anim}
:left {:walk (utils/flip walk-right)
:stand (utils/flip stand-anim)
:talk (utils/flip talk-anim)
:squat (utils/flip squat-anim)
:reach (utils/flip reach-anim)
:cat-toy (utils/flip cat-toy-anim)}
:cat-toy (utils/flip cat-toy-anim)
[:fire 1] (utils/flip fire-1-anim)
[:fire 2] (utils/flip fire-2-anim)
[:fire 3] (utils/flip fire-3-anim)}
:baseline 95
:facing :right
:origin-x 9
@@ -182,7 +195,9 @@
:inside-fangald (make-music "inside-fangald.ogg")}
:state {:object nil
:active? true
:inventory []}
:inventory []
:clues #{}
:mints-eaten 0}
:actions {:object nil
:channel (chan)
:current nil

View File

@@ -11,7 +11,7 @@
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
(println (:input-x screen) (:input-y screen) "->" x y)))
(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :stool :stick :cat-toy :balloon :frog-legs])
(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :stool :stick :cat-toy :balloon :frog-legs :teddy :portrait])
(defn cursor [filename which]
(let [scale 2