diff --git a/desktop/resources/behindhouse/background.png b/desktop/resources/behindhouse/background.png
index 8e695081..3bcc00ee 100644
Binary files a/desktop/resources/behindhouse/background.png and b/desktop/resources/behindhouse/background.png differ
diff --git a/desktop/resources/behindhouse/house-cover.png b/desktop/resources/behindhouse/house-cover.png
new file mode 100644
index 00000000..c537ef5e
Binary files /dev/null and b/desktop/resources/behindhouse/house-cover.png differ
diff --git a/desktop/resources/behindhouse/house.png b/desktop/resources/behindhouse/house.png
index 993cd89a..6b907882 100644
Binary files a/desktop/resources/behindhouse/house.png and b/desktop/resources/behindhouse/house.png differ
diff --git a/desktop/resources/behindhouse/stick.png b/desktop/resources/behindhouse/stick.png
new file mode 100644
index 00000000..9513670b
Binary files /dev/null and b/desktop/resources/behindhouse/stick.png differ
diff --git a/desktop/resources/cursor.png b/desktop/resources/cursor.png
index 9e0ef7d3..824741df 100644
Binary files a/desktop/resources/cursor.png and b/desktop/resources/cursor.png differ
diff --git a/desktop/resources/ego/cat-toy.png b/desktop/resources/ego/cat-toy.png
new file mode 100644
index 00000000..0f7fb76d
Binary files /dev/null and b/desktop/resources/ego/cat-toy.png differ
diff --git a/desktop/resources/ego/cat-toy.pxa/0.pxi b/desktop/resources/ego/cat-toy.pxa/0.pxi
new file mode 100644
index 00000000..ce12746e
Binary files /dev/null and b/desktop/resources/ego/cat-toy.pxa/0.pxi differ
diff --git a/desktop/resources/ego/cat-toy.pxa/1.pxi b/desktop/resources/ego/cat-toy.pxa/1.pxi
new file mode 100644
index 00000000..080494ea
Binary files /dev/null and b/desktop/resources/ego/cat-toy.pxa/1.pxi differ
diff --git a/desktop/resources/ego/cat-toy.pxa/2.pxi b/desktop/resources/ego/cat-toy.pxa/2.pxi
new file mode 100644
index 00000000..4fe42c5e
Binary files /dev/null and b/desktop/resources/ego/cat-toy.pxa/2.pxi differ
diff --git a/desktop/resources/ego/cat-toy.pxa/3.pxi b/desktop/resources/ego/cat-toy.pxa/3.pxi
new file mode 100644
index 00000000..69e52ea8
Binary files /dev/null and b/desktop/resources/ego/cat-toy.pxa/3.pxi differ
diff --git a/desktop/resources/ego/cat-toy.pxa/4.pxi b/desktop/resources/ego/cat-toy.pxa/4.pxi
new file mode 100644
index 00000000..413a5e5b
Binary files /dev/null and b/desktop/resources/ego/cat-toy.pxa/4.pxi differ
diff --git a/desktop/resources/ego/cat-toy.pxa/CelData.plist b/desktop/resources/ego/cat-toy.pxa/CelData.plist
new file mode 100644
index 00000000..1ff35422
--- /dev/null
+++ b/desktop/resources/ego/cat-toy.pxa/CelData.plist
@@ -0,0 +1,26 @@
+
+
+
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+
diff --git a/desktop/resources/ego/reach.png b/desktop/resources/ego/reach.png
new file mode 100644
index 00000000..42f6983d
Binary files /dev/null and b/desktop/resources/ego/reach.png differ
diff --git a/desktop/resources/ego/reach.pxa/0.pxi b/desktop/resources/ego/reach.pxa/0.pxi
new file mode 100644
index 00000000..0422adf5
Binary files /dev/null and b/desktop/resources/ego/reach.pxa/0.pxi differ
diff --git a/desktop/resources/ego/reach.pxa/1.pxi b/desktop/resources/ego/reach.pxa/1.pxi
new file mode 100644
index 00000000..b59db78e
Binary files /dev/null and b/desktop/resources/ego/reach.pxa/1.pxi differ
diff --git a/desktop/resources/ego/reach.pxa/2.pxi b/desktop/resources/ego/reach.pxa/2.pxi
new file mode 100644
index 00000000..c726a671
Binary files /dev/null and b/desktop/resources/ego/reach.pxa/2.pxi differ
diff --git a/desktop/resources/ego/reach.pxa/3.pxi b/desktop/resources/ego/reach.pxa/3.pxi
new file mode 100644
index 00000000..1a305b73
Binary files /dev/null and b/desktop/resources/ego/reach.pxa/3.pxi differ
diff --git a/desktop/resources/ego/reach.pxa/CelData.plist b/desktop/resources/ego/reach.pxa/CelData.plist
new file mode 100644
index 00000000..f0b74d60
--- /dev/null
+++ b/desktop/resources/ego/reach.pxa/CelData.plist
@@ -0,0 +1,22 @@
+
+
+
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+
diff --git a/desktop/resources/ego/squat.png b/desktop/resources/ego/squat.png
new file mode 100644
index 00000000..d19f6a8d
Binary files /dev/null and b/desktop/resources/ego/squat.png differ
diff --git a/desktop/resources/ego/squat.pxa/0.pxi b/desktop/resources/ego/squat.pxa/0.pxi
new file mode 100644
index 00000000..23323cab
Binary files /dev/null and b/desktop/resources/ego/squat.pxa/0.pxi differ
diff --git a/desktop/resources/ego/squat.pxa/1.pxi b/desktop/resources/ego/squat.pxa/1.pxi
new file mode 100644
index 00000000..a34e70aa
Binary files /dev/null and b/desktop/resources/ego/squat.pxa/1.pxi differ
diff --git a/desktop/resources/ego/squat.pxa/2.pxi b/desktop/resources/ego/squat.pxa/2.pxi
new file mode 100644
index 00000000..0cbb09f7
Binary files /dev/null and b/desktop/resources/ego/squat.pxa/2.pxi differ
diff --git a/desktop/resources/ego/squat.pxa/3.pxi b/desktop/resources/ego/squat.pxa/3.pxi
new file mode 100644
index 00000000..6c6c8de1
Binary files /dev/null and b/desktop/resources/ego/squat.pxa/3.pxi differ
diff --git a/desktop/resources/ego/squat.pxa/CelData.plist b/desktop/resources/ego/squat.pxa/CelData.plist
new file mode 100644
index 00000000..f0b74d60
--- /dev/null
+++ b/desktop/resources/ego/squat.pxa/CelData.plist
@@ -0,0 +1,22 @@
+
+
+
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+
diff --git a/desktop/resources/inside-castle/background.png b/desktop/resources/inside-castle/background.png
index 6351bd0c..54f779a2 100644
Binary files a/desktop/resources/inside-castle/background.png and b/desktop/resources/inside-castle/background.png differ
diff --git a/desktop/resources/inside-castle/game-player-talk.png b/desktop/resources/inside-castle/game-player-talk.png
new file mode 100644
index 00000000..d4c88beb
Binary files /dev/null and b/desktop/resources/inside-castle/game-player-talk.png differ
diff --git a/desktop/resources/inside-castle/game-player-talk.pxa/0.pxi b/desktop/resources/inside-castle/game-player-talk.pxa/0.pxi
new file mode 100644
index 00000000..da062ca1
Binary files /dev/null and b/desktop/resources/inside-castle/game-player-talk.pxa/0.pxi differ
diff --git a/desktop/resources/inside-castle/game-player-talk.pxa/1.pxi b/desktop/resources/inside-castle/game-player-talk.pxa/1.pxi
new file mode 100644
index 00000000..e10ecd68
Binary files /dev/null and b/desktop/resources/inside-castle/game-player-talk.pxa/1.pxi differ
diff --git a/desktop/resources/inside-castle/game-player-talk.pxa/2.pxi b/desktop/resources/inside-castle/game-player-talk.pxa/2.pxi
new file mode 100644
index 00000000..3297d2d9
Binary files /dev/null and b/desktop/resources/inside-castle/game-player-talk.pxa/2.pxi differ
diff --git a/desktop/resources/inside-castle/game-player-talk.pxa/3.pxi b/desktop/resources/inside-castle/game-player-talk.pxa/3.pxi
new file mode 100644
index 00000000..d0554cfd
Binary files /dev/null and b/desktop/resources/inside-castle/game-player-talk.pxa/3.pxi differ
diff --git a/desktop/resources/inside-castle/game-player-talk.pxa/CelData.plist b/desktop/resources/inside-castle/game-player-talk.pxa/CelData.plist
new file mode 100644
index 00000000..f0b74d60
--- /dev/null
+++ b/desktop/resources/inside-castle/game-player-talk.pxa/CelData.plist
@@ -0,0 +1,22 @@
+
+
+
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+ duration
+ 1
+
+
+
diff --git a/desktop/resources/inside-castle/gameplayer.png b/desktop/resources/inside-castle/gameplayer.png
new file mode 100644
index 00000000..26ee83fc
Binary files /dev/null and b/desktop/resources/inside-castle/gameplayer.png differ
diff --git a/desktop/resources/inside-castle/gameplayer.pxi b/desktop/resources/inside-castle/gameplayer.pxi
new file mode 100644
index 00000000..36300170
Binary files /dev/null and b/desktop/resources/inside-castle/gameplayer.pxi differ
diff --git a/desktop/resources/inside-castle/player.pxi b/desktop/resources/inside-castle/player.pxi
new file mode 100644
index 00000000..36300170
Binary files /dev/null and b/desktop/resources/inside-castle/player.pxi differ
diff --git a/desktop/resources/inside-fangald.mp3 b/desktop/resources/inside-fangald.mp3
new file mode 100644
index 00000000..fa868020
Binary files /dev/null and b/desktop/resources/inside-fangald.mp3 differ
diff --git a/desktop/resources/inside-fangald.ogg b/desktop/resources/inside-fangald.ogg
new file mode 100644
index 00000000..d282bae9
Binary files /dev/null and b/desktop/resources/inside-fangald.ogg differ
diff --git a/desktop/resources/megaboss.mp3 b/desktop/resources/megaboss.mp3
new file mode 100644
index 00000000..3dc3cc80
Binary files /dev/null and b/desktop/resources/megaboss.mp3 differ
diff --git a/desktop/resources/outside-castle/steer.png b/desktop/resources/outside-castle/steer.png
new file mode 100644
index 00000000..d5f1b880
Binary files /dev/null and b/desktop/resources/outside-castle/steer.png differ
diff --git a/desktop/resources/outside-castle/steer.pxi b/desktop/resources/outside-castle/steer.pxi
new file mode 100644
index 00000000..7730acb9
Binary files /dev/null and b/desktop/resources/outside-castle/steer.pxi differ
diff --git a/desktop/resources/town-music-1.ogg b/desktop/resources/town-music-1.ogg
new file mode 100644
index 00000000..e46d3bad
Binary files /dev/null and b/desktop/resources/town-music-1.ogg differ
diff --git a/desktop/resources/town-music-2.mp3 b/desktop/resources/town-music-2.mp3
new file mode 100644
index 00000000..4831e102
Binary files /dev/null and b/desktop/resources/town-music-2.mp3 differ
diff --git a/desktop/resources/town-music-2.ogg b/desktop/resources/town-music-2.ogg
new file mode 100644
index 00000000..4f8a341a
Binary files /dev/null and b/desktop/resources/town-music-2.ogg differ
diff --git a/desktop/resources/town-music.ogg b/desktop/resources/town-music.ogg
new file mode 100644
index 00000000..f8450ef5
Binary files /dev/null and b/desktop/resources/town-music.ogg differ
diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj
index 80b35bad..4fdd053e 100644
--- a/desktop/src-common/advent/actions.clj
+++ b/desktop/src-common/advent/actions.clj
@@ -23,6 +23,8 @@
(can-skip? [this screen entities])
(get-channel [this]))
+(defn has-item? [entities item]
+ ((set (get-in entities [:state :inventory])) item))
(defmacro get-script [entities & forms]
`(fn [starting-entities#]
@@ -36,22 +38,25 @@
:y y
:baseline (- 240 y))]
(if (:scaled entity)
- (assoc entity :scale-x (scale-fn y) :scale-y (scale-fn y))
+ (assoc entity :scale-x (scale-fn [x y]) :scale-y (scale-fn [x y]))
entity)))
+(defn find-animation [entity anim]
+ (if (keyword? anim)
+ (or (get-in entity [(:facing entity) anim])
+ (anim entity))
+ anim))
+
(defn start-animation [screen entity anim]
- (let [new-anim (if (keyword? anim)
- (or (get-in entity [(:facing entity) anim])
- (anim entity))
- anim)]
+ (let [new-anim (find-animation entity anim)]
(if (and anim (not= new-anim (:anim entity)))
(assoc entity
:anim new-anim
:anim-start (:total-time screen))
entity)))
-(defn stop [screen entities target-id]
- (update-in entities [:room :entities target-id] #(start-animation screen % :stand)))
+(defn stop [screen entities target-id & {:keys [face]}]
+ (update-in entities [:room :entities target-id] (comp #(start-animation screen % :stand) (if face #(assoc % :facing face) identity))))
(defmacro run-action [entities & forms]
@@ -105,7 +110,36 @@
(can-skip? [this screen entities]
false))))
-(defn walk-to [entities target-id [final-x final-y] & [can-skip?]]
+(defn play-animation [entities target-id anim]
+ (run-action entities
+ (begin [this screen entities]
+ (update-in entities [:room :entities target-id] #(start-animation screen % anim) ))
+
+ (continue [this screen entities] entities)
+
+ (done? [this screen entities]
+ (animation! (find-animation (get-in entities [:room :entities target-id ]) anim)
+ :is-animation-finished
+ (- (:total-time screen) (get-in entities [:room :entities target-id :anim-start]))))
+
+ (terminate [this screen entities]
+ (stop screen entities target-id))
+ (can-skip? [this screen entities]
+ false)))
+
+(defn update-entity [entities target-id f]
+ (run-action entities
+ (begin [this screen entities]
+ (update-in entities [:room :entities target-id] f))
+
+ (continue [this screen entities] entities)
+
+ (done? [this screen entities] true)
+
+ (terminate [this screen entities] entities)
+ (can-skip? [this screen entities] false)))
+
+(defn walk-to [entities target-id [final-x final-y] & {:keys [can-skip? face]}]
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
final-x (int final-x)
final-y (int final-y)
@@ -154,7 +188,7 @@
(< (utils/dist final-x final-y from-x from-y) 1)))
(terminate [this screen entities]
- (stop screen entities target-id))
+ (stop screen entities target-id :face face))
(can-skip? [this screen entities]
(or can-skip? false)))
@entities)))
@@ -169,10 +203,11 @@
(begin [this screen entities]
(let [_ (swap! initial-time #(or % (:total-time screen)))
target-y (get-in entities [:room :entities target-id :y])
+ target-x (get-in entities [:room :entities target-id :x])
scale-fn (get-in entities [:room :scale-fn])
- scale (scale-fn target-y)
+ scale (scale-fn [target-x target-y])
height (* scale 36)]
- (run! dialogue/talking-screen :on-talk :text text
+ (screen! dialogue/talking-screen :on-talk :text text
:x (get-in entities [:room :entities target-id :x]) :y (+ (get-in entities [:room :entities target-id :y]) height)
:target-id target-id
:scale scale)
@@ -186,7 +221,7 @@
(get-text-duration text)))
(terminate [this screen entities]
- (run! dialogue/talking-screen :stop-talk :target-id target-id)
+ (screen! dialogue/talking-screen :stop-talk :target-id target-id)
(if stop?
(stop screen entities target-id)
entities))
@@ -207,17 +242,17 @@
(recur (inc so-far) (zip/right zipper)))))
(defn make-zipper [tree]
- (zip/zipper map? (comp #(map second %) #(partition 2 %) :choices) (fn [n c] nil) tree))
+ (zip/zipper map? (comp #(map second %) #(filter first (partition 2 %)) :choices) (fn [n c] nil) tree))
(defn present-choices [entities choices]
(loop [zipper (make-zipper choices)]
(let [selected-index (atom nil)
node (zip/node zipper)
- dialogue-choices (partition 2 (:choices node))]
+ dialogue-choices (filter first (partition 2 (:choices node)))]
(run-action entities
(begin [this screen entities]
- (run! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %))
- (run! @(resolve 'advent.screens.scene/scene) :on-deactivate)
+ (screen! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %))
+ (screen! @(resolve 'advent.screens.scene/scene) :on-deactivate)
entities)
(continue [this screen entities] entities)
@@ -225,7 +260,7 @@
(done? [this screen entities] (not (nil? @selected-index)))
(terminate [this screen entities]
- (run! @(resolve 'advent.screens.scene/scene) :on-reactivate)
+ (screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
entities)
(can-skip? [this screen entities]
false))
@@ -252,6 +287,22 @@
(can-skip? [this screen entities]
false)))
+(defn remove-item [entities item]
+ (run-action entities
+ (begin [this screen entities]
+ (-> entities
+ (update-in [:state :inventory] #(remove (partial = item) %))
+ (assoc-in [:cursor :current] :main)))
+
+ (continue [this screen entities] entities)
+
+ (done? [this screen entities] true)
+
+ (terminate [this screen entities]
+ entities)
+ (can-skip? [this screen entities]
+ false)))
+
(defn give [entities item]
(run-action entities
(begin [this screen entities]
@@ -259,7 +310,7 @@
(-> entities
(update-in [:state :inventory] #(conj % item))
- (assoc-in [:cursor :current] item)))
+ (assoc-in [:cursor :current] (:cursor item))))
(continue [this screen entities] entities)
@@ -285,47 +336,63 @@
false)))
(defn transition-background [entities new-background [x y]]
- (run-action entities
- (begin [this screen entities]
-
- (-> entities
- (assoc-in [:transition]
- (assoc (texture "black.png")
- :scale-x 20
- :scale-y 20
- :baseline 9500
- :opacity 0.1))))
-
- (continue [this screen entities]
- (update-in entities [:transition :opacity] + 0.075))
-
- (done? [this screen entities]
- (>= (get-in entities [:transition :opacity]) 1.0))
-
- (terminate [this screen entities]
- entities)
- (can-skip? [this screen entities]
- false))
- (run-action entities
- (begin [this screen entities]
- (let [ego (get-in entities [:room :entities :ego])
- entities (-> entities
- (assoc-in [:room] (get-in entities [:rooms new-background]))
- (assoc-in [:room :entities :ego] ego))]
+ (let [old-music (get-in @entities [:room :music])
+ new-music (get-in @entities [:rooms new-background :music])
+ music-changed? (not= old-music new-music)]
+ (run-action entities
+ (begin [this screen entities]
+
(-> entities
- (update-in [:room :entities :ego] #(jump-to screen entities % [x y])))))
+ (assoc-in [:transition]
+ (assoc (texture "black.png")
+ :scale-x 20
+ :scale-y 20
+ :baseline 9500
+ :opacity 0.1))))
- (continue [this screen entities]
- (update-in entities [:transition :opacity] - 0.075))
+ (continue [this screen entities]
+ (when music-changed?
+ (music! (get-in entities [:musics old-music]) :set-volume (max (- 1.0 (get-in entities [:transition :opacity])) 0.0)))
+ (update-in entities [:transition :opacity] + 0.05))
- (done? [this screen entities]
- (<= (get-in entities [:transition :opacity]) 0.0))
+ (done? [this screen entities]
+ (>= (get-in entities [:transition :opacity]) 1.0))
- (terminate [this screen entities]
- (dissoc entities :transition))
+ (terminate [this screen entities]
+ entities)
+ (can-skip? [this screen entities]
+ false))
+ (run-action entities
+ (begin [this screen entities]
+ (let [ego (get-in entities [:room :entities :ego])
+ old-music (get-in entities [:room :music])
+ entities (-> entities
+ (assoc-in [:room] (get-in entities [:rooms new-background]))
+ (assoc-in [:room :entities :ego] ego))
+ new-music (get-in entities [:room :music])]
+ (when (not= new-music old-music)
+ (doseq [[k v] (:musics entities)
+ :when (and v (not= new-music k))]
+ (music! v :stop))
+ (when new-music
+ (music! (get-in entities [:musics new-music]) :set-volume 0)
+ (music! (get-in entities [:musics new-music]) :play)))
+ (-> entities
+ (update-in [:room :entities :ego] #(jump-to screen entities % [x y])))))
- (can-skip? [this screen entities]
- false)))
+ (continue [this screen entities]
+ (when music-changed?
+ (music! (get-in entities [:musics new-music]) :set-volume (max (- 1.0 (get-in entities [:transition :opacity])) 0.0)))
+ (update-in entities [:transition :opacity] - 0.075))
+
+ (done? [this screen entities]
+ (<= (get-in entities [:transition :opacity]) 0.0))
+
+ (terminate [this screen entities]
+ (dissoc entities :transition))
+
+ (can-skip? [this screen entities]
+ false))))
(defn do-dialogue [entities & pairs]
(loop [pairs (partition 2 pairs)]
diff --git a/desktop/src-common/advent/screens/dialogue.clj b/desktop/src-common/advent/screens/dialogue.clj
index b0bfe9ad..ef03a484 100644
--- a/desktop/src-common/advent/screens/dialogue.clj
+++ b/desktop/src-common/advent/screens/dialogue.clj
@@ -37,16 +37,14 @@
(let [font (bitmap-font "ego/font.fnt" )
tr (bitmap-font! font :get-region)
scale (or (min (max scale 0.75) 1) 1)
- width (/ (game :width) 1.5)
tx (.getTexture tr)
_ (texture! tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)
- talk (assoc (label text (style :label font (color :white))) :x (- (* 4 x) (/ width 2)) :y (* 4 y))
- talk (ensure-on-screen talk)]
- (label! talk :set-wrap true)
- (label! talk :set-width width)
+ talk (assoc (label text (style :label font (color :white))) :y (* 4 y))]
(label! talk :set-font-scale scale)
(label! talk :set-alignment Align/center)
- (assoc entities target-id talk)))
+ (assoc entities target-id (-> talk
+ (assoc :x (- (* 4 x) (/ (label! talk :get-width) 2)))
+ ensure-on-screen ))))
:stop-talk
(fn [{:keys [target-id] } [entities]]
@@ -79,7 +77,7 @@
[i (assoc (label text (style :label font (color :white))) :x 30 :y (* 30 i))]))
(assoc :state {:object nil :callback callback :choices choices}))))
- :on-touch-down (fn [screen [entities]]
+ :on-touch-up (fn [screen [entities]]
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
(when (seq entities)
(when (< y (* 30 (dec (count entities))))
diff --git a/desktop/src-common/advent/screens/inventory.clj b/desktop/src-common/advent/screens/inventory.clj
index bc04b0fc..9bd98c11 100644
--- a/desktop/src-common/advent/screens/inventory.clj
+++ b/desktop/src-common/advent/screens/inventory.clj
@@ -14,6 +14,12 @@
InputMultiplexer InputProcessor Net Preferences Screen]))
+(defn close [entities]
+ (screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
+ (-> entities
+ (assoc :shown? false)
+ (assoc :start-showing? false)))
+
(defscreen inventory-screen
:on-show
@@ -45,7 +51,7 @@
(render! screen [(:fade entities) (:overlay entities)])
(render! screen (:items entities))
(if-let [item (:highlighted-item entities)]
- (label! (:highlighted-text entities) :set-text (name item))
+ (label! (:highlighted-text entities) :set-text (:name item))
(label! (:highlighted-text entities) :set-text ""))
(render! screen [(:highlighted-text entities)]))
entities))
@@ -60,7 +66,7 @@
offset-y (+ y (/ item-width 2))
padding (/ item-width 2)
padding (* 4 padding)]]
- (assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ item)))
+ (assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
:x x :y y
:scale-x 4
:scale-y 4
@@ -74,16 +80,21 @@
(assoc entities :highlighted-item (:item selected-entity))
(assoc entities :highlighted-item nil))))
- :on-touch-down (fn [screen [entities]]
+ :on-touch-up (fn [screen [entities]]
(when (:shown? entities)
- (run! @(resolve 'advent.screens.scene/scene) :on-reactivate)
- (let [{:keys [highlighted-item]} entities]
- (when highlighted-item
- (run! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item)))
- (-> entities
- (assoc :shown? false)
- (assoc :start-showing? false))))
+ (let [{:keys [highlighted-item]} entities
+ room-entities (-> @(resolve 'advent.screens.scene/scene)
+ :entities
+ deref
+ first)
+ current-cursor (get-in room-entities [:cursor :current])]
+ (if highlighted-item
+ (if (= :main current-cursor)
+ (screen! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item)
+ (when-let [interaction-script ((or (:scripts highlighted-item) (constantly nil)) (:value current-cursor))]
+ (interaction-script room-entities)
+ (close entities)))
+ (close entities)))))
:on-resize (fn [screen entities]
- (height! screen 960)
- entities))
+ (size! screen 1280 960)))
diff --git a/desktop/src-common/advent/screens/items.clj b/desktop/src-common/advent/screens/items.clj
new file mode 100644
index 00000000..2dbddcae
--- /dev/null
+++ b/desktop/src-common/advent/screens/items.clj
@@ -0,0 +1,52 @@
+(ns advent.screens.items
+ (:require [advent.actions :as actions]))
+
+
+(declare stick)
+(declare wool)
+(declare cat-toy)
+(declare flask-1-with-milk)
+(def make-cat-toy
+ (actions/get-script entities
+ (actions/remove-item entities stick)
+ (actions/remove-item entities wool)
+ (actions/give entities cat-toy)
+ (actions/talk entities :ego "It makes a little cat toy!")))
+
+(def wool {:name "Wool" :value :wool :cursor :wool :scripts {:stick make-cat-toy}})
+(def mushrooms {:name "Mushrooms" :value :mushrooms :cursor :mushrooms})
+(def carrot {:name "Carrot" :value :carrot :cursor :carrot})
+
+(def flask-1-with-mushrooms {:name "Flask with mushrooms" :value :flask-1-with-mushrooms :cursor :flask-with-contents})
+(def flask-1-with-cream-of-mushroom {:name "Flask with cream of mushrooms soup" :value :flask-1-with-cream-of-mushroom :cursor :flask-with-contents})
+
+
+(defn make-cream-of-mushroom []
+ (actions/get-script entities
+ (actions/remove-item entities flask-1-with-mushrooms)
+ (actions/remove-item entities flask-1-with-milk)
+ (actions/remove-item entities mushrooms)
+ (actions/give entities flask-1-with-cream-of-mushroom)
+ (actions/talk entities :ego "It's just like cream of mushroom soup.")))
+
+(def flask-1-with-milk {:name "Flask with milk" :value :flask-1-with-milk :cursor :flask-with-contents
+ :scripts {:mushrooms (make-cream-of-mushroom)}})
+
+(def flask-1-strength {:name "Strength potion" :value :flask-1-strength :cursor :flask-with-contents})
+(def flask-1 {:name "Flask" :value :flask-1 :cursor :flask
+ :scripts {:mushrooms (actions/get-script entities
+ (actions/remove-item entities flask-1)
+ (actions/remove-item entities mushrooms)
+ (actions/give entities flask-1-with-mushrooms)
+ (actions/talk entities :ego "I'll just put a few of these in here."))}})
+
+(def trophy {:name "Trophy of wisdom" :value :trophy :cursor :trophy})
+(def cheat-deck {:name "Warlock's Tower cheat deck" :value :cheat-deck :cursor :cheat-deck})
+
+(def cat-toy {:name "Cat toy" :value :cat-toy :cursor :cat-toy})
+(def stick {:name "Stick" :value :stick :cursor :stick :scripts {:wool make-cat-toy}})
+(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})
+
+
diff --git a/desktop/src-common/advent/screens/rooms.clj b/desktop/src-common/advent/screens/rooms.clj
index 4ebc4c0f..2c042b69 100644
--- a/desktop/src-common/advent/screens/rooms.clj
+++ b/desktop/src-common/advent/screens/rooms.clj
@@ -8,7 +8,8 @@
:get-script (fn [cursor [x y]]
(if (= :main cursor)
(:script spec)
- (get-in spec [:scripts cursor])))}))
+ (when-let [scripts (:scripts spec)]
+ (scripts (:value cursor)))))}))
entities (into {} (for [[id entity] entities]
[id (merge entity
{:mouse-in? (fn [entities x y]
@@ -20,7 +21,8 @@
{:get-script (fn [cursor [x y]]
(if (= :main cursor)
(:script entity)
- (get-in entity [:scripts cursor])))}))]))]
+ (when-let [scripts (:scripts entity)]
+ (scripts (:value cursor)))))}))]))]
(merge params {:collision (advent.pathfind/map-from-resource collision)
:interactions interactions-as-list
:entities entities})))
diff --git a/desktop/src-common/advent/screens/rooms/behind_house.clj b/desktop/src-common/advent/screens/rooms/behind_house.clj
index 586c61e3..9276c03f 100644
--- a/desktop/src-common/advent/screens/rooms/behind_house.clj
+++ b/desktop/src-common/advent/screens/rooms/behind_house.clj
@@ -1,5 +1,6 @@
(ns advent.screens.rooms.behind-house
(:require [advent.screens.rooms :as rooms]
+ [advent.screens.items :as items]
[advent.actions :as actions]
[advent.utils :as utils]
[clojure.zip :as zip]
@@ -9,7 +10,8 @@
[play-clj.g2d :refer :all]))
(defn make [screen]
- (rooms/make :interactions
+ (rooms/make :music :town-2
+ :interactions
{:left-dir {:box [0 131 20 224]
:script (actions/get-script
entities
@@ -17,22 +19,19 @@
(actions/transition-background entities :outside-house [244 150])
(actions/walk-to entities :ego [195 140]))
:cursor :left}
- :crack {:box [68 100 73 114]
- :script (actions/get-script
- entities
- (actions/walk-to entities :ego [70 80])
- (actions/talk entities :ego "I can see Fangald, the wizard inside.")
- (actions/talk entities :ego "It looks like he's opening his Magi-safe.")
- (actions/talk entities :ego "[todo: sounds play.]")
- (actions/talk entities :ego "A lot of good it'll do me to know his password while he's still there."))}
+ #_:crack #_{:box [68 100 73 114]
+ :script (actions/get-script
+ entities
+ )}
:mushrooms {:box [247 59 269 76]
:script (actions/get-script
entities
- (if ((get-in @entities [:state :inventory]) :mushrooms)
+ (if (actions/has-item? @entities items/mushrooms)
(actions/talk entities :ego "I've already got a junk ton of mushrooms.")
(do
(actions/walk-to entities :ego [242 75])
- (actions/give entities :mushrooms)
+ (actions/play-animation entities :ego :squat)
+ (actions/give entities items/mushrooms)
(actions/talk entities :ego "Perfectly ripe mushrooms!"))))}
:window {:box [103 44 130 140]
:script (actions/get-script
@@ -42,6 +41,32 @@
:layers [(assoc (texture "behindhouse/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "behindhouse/house.png") :x 0 :y 0 :baseline 122)
(assoc (texture "behindhouse/brush.png") :x 0 :y 0 :baseline 240)]
- :entities {}
+ :entities {:stick (assoc (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 items/stick)
+ (actions/talk entities :ego "This stick might be useful.")
+ ))
+ :peeling (assoc (texture "behindhouse/house-cover.png")
+ :x 60 :y 92 :baseline 148
+ :script (actions/get-script entities
+ (if (get-in @entities [:state :opened-crack?])
+ (do (actions/walk-to entities :ego [70 80])
+ (actions/play-animation entities :ego :squat)
+ (actions/talk entities :ego "I can see Gandarf, the wizard inside.")
+ (actions/play-animation entities :ego :squat)
+ (actions/talk entities :ego "It looks like he's opening his Magi-safe.")
+ (actions/play-animation entities :ego :squat)
+ (actions/talk entities :ego "[todo: sounds play.]")
+ (actions/play-animation entities :ego :squat)
+ (actions/talk entities :ego "A lot of good it'll do me to know his password while he's still there."))
+ (do (actions/walk-to entities :ego [80 80])
+ (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)))))))}
:collision "behindhouse/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)))
diff --git a/desktop/src-common/advent/screens/rooms/cat_tree.clj b/desktop/src-common/advent/screens/rooms/cat_tree.clj
index da8b25ac..d8b7360f 100644
--- a/desktop/src-common/advent/screens/rooms/cat_tree.clj
+++ b/desktop/src-common/advent/screens/rooms/cat_tree.clj
@@ -12,7 +12,8 @@
(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)))]
- (rooms/make :interactions
+ (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])
@@ -27,7 +28,10 @@
:x 184 :y 173 :baseline 240
:script (actions/get-script entities
(actions/talk entities :ego "Here kitty, kitty, kitty.")
- (actions/talk entities :ego "Kitty's not so interested in me.")))
+ (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)
+ (actions/talk entities :ego "I guess I'm too far away."))})
cat-stand)}
:collision "cat-tree/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.20))))
diff --git a/desktop/src-common/advent/screens/rooms/inside_castle.clj b/desktop/src-common/advent/screens/rooms/inside_castle.clj
new file mode 100644
index 00000000..04ce1a76
--- /dev/null
+++ b/desktop/src-common/advent/screens/rooms/inside_castle.clj
@@ -0,0 +1,157 @@
+(ns advent.screens.rooms.inside-castle
+ (: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 play-warlocks-castle [entities]
+ (let [scenarios [#(actions/do-dialogue entities
+ :game-player "As you approach the lair of the cave beast, a foul odor fills your nostrils."
+ :game-player "To your horror, you realize that the stench is from the corpses of less wise wizards."
+ :game-player "The cave is eerie and dark. What do you do?")
+ #(actions/do-dialogue entities
+ :game-player "As you move forward in your quest, you come upon an abandoned library."
+ :game-player "Still, something doesn't feel right about the place."
+ :game-player "It's quiet."
+ :game-player "A little too quiet.")
+ #(actions/do-dialogue entities
+ :game-player "The treacherous stair lies before you.")]]
+ (doseq [scenario (take 2 (shuffle scenarios))]
+ (scenario))))
+
+(defn do-game-player-dialogue [entities]
+ (actions/do-dialogue entities :ego "You there!" :game-player "... Yes?")
+ (actions/present-choices entities
+ {:choices ["Do you know anything about the sword in the stone up there?"
+ {:run #(actions/respond entities %
+ :game-player "It is said that only he who is worthy in wisdom can pull the sword!"
+ :game-player "I, of course have such wisdom, but I'm still unable to pull it myself.")
+ :choices ["Can you teach me your ways?"
+ {:run #(actions/respond entities %
+ :game-player "Ha! My intellect has only been achieved with years of precise training!"
+ :game-player "You're out of luck, friend. Unless you are willing to spend hours and hours in careful study, you will always be a dunce."
+ :ego "...")
+ :choices actions/previous-choices}
+ "How come?"
+ {:run #(actions/respond entities %
+ :game-player "You must be mighty in strength to pull the sword."
+ :game-player "And I spend all of my time either playing my game, or at the library.")
+ :choices actions/previous-choices}
+ "Something else."
+ {:choices actions/something-else}]}
+ (when (= nil (get-in @entities [:state :current-riddle]))
+ "Nice trophy.")
+ {:run #(actions/respond entities %
+ :game-player "Thanks. I was nominated the Riddlemaster of Remington for the 7th straight year!"
+ :game-player "I guess I'm pretty wise."
+ :game-player "And with my sharp intellect, I'm guessing you want my trophy?")
+ :choices ["Yes."
+ {:run #(do (actions/update-state entities (fn [state] (assoc state :current-riddle :wool)))
+ (actions/respond entities %
+ :game-player "Well, if you want my trophy, you'll have to earn it."
+ :game-player "There are a few riddles that even I, the wisest in all of Remington, cannot solve."
+ :game-player "How about you help me?"
+ :game-player "Bring me the answer:"
+ :game-player "White as snow, but not as cold,"
+ :game-player "Keeps you warm, or so I'm told."
+ :ego "Okay."))}
+ "No."
+ {:run #(actions/respond entities %
+ :game-player "That's exactly what I'd expect a dummy like you to say.")
+ :choices actions/something-else}]}
+
+ (when (= :wool (get-in @entities [:state :current-riddle]))
+ "What was that riddle again?")
+ {:run #(actions/respond entities %
+ :game-player "White as snow, but not as cold,"
+ :game-player "Keeps you warm, or so I'm told.")
+ :choices actions/previous-choices}
+
+ (when (= :balloon (get-in @entities [:state :current-riddle]))
+ "What was that riddle again?")
+ {:run #(actions/respond entities %
+ :game-player "Filled with air, light as a feather,"
+ :game-player "If you want to keep it, best have a tether.")
+ :choices actions/previous-choices}
+
+ (when (= :frog-legs (get-in @entities [:state :current-riddle]))
+ "What was that riddle again?")
+ {:run #(actions/respond entities %
+ :game-player "Hippity-hop, I jump real far,"
+ :game-player "Now I'm dead, or at least have a scar.")
+ :choices actions/previous-choices}
+ "Nevermind."
+ {:run #(actions/respond entities % :game-player "See you around.")}]}))
+
+(defn make [screen]
+ (let [game-player-talk-sheet (texture! (texture "inside-castle/game-player-talk.png") :split 40 44)
+ game-player-talk (animation 0.15 (for [i [0 2 0 2 0 2 0 3 0 2 0 1 0 0 0 0 2 0 2 0 3 0 1 0 1 0 0 1 0 2 0 3 0]]
+ (aget game-player-talk-sheet 0 i)))]
+ (rooms/make :music :town-1
+ :interactions
+ {:right-door {:box [286 140 306 160]
+ :cursor :right
+ :script (actions/get-script entities
+ (actions/walk-to entities :ego [284 145])
+ (actions/transition-background entities :outside-castle [82 180])
+ (actions/walk-to entities :ego [129 148]))}
+ :sword {:box [0 130 39 165]
+ :script (actions/get-script entities
+ (actions/talk entities :ego "That's the coolest sword I've ever seen!!")
+ (actions/walk-to entities :ego [37 134] :face :left)
+ (actions/talk entities :ego "Maybe I can pull it out.")
+ (actions/play-animation entities :ego :reach)
+ (actions/do-dialogue entities
+ :ego "I can't pull it out!"
+ :ego "It looks like there's an enscription here.")
+ (actions/play-animation entities :ego :squat)
+ (actions/do-dialogue entities
+ :ego "The Sword of Blergh with magic sting,"
+ :ego "shall yield to no earthly king."
+ :ego "Worthy in wisdom, courage, and might,"
+ :ego "only then with sword he'll fight."))}
+ :sign {:box [125 140 165 155]
+ :script (actions/get-script entities
+ (actions/talk entities :ego "Ye Ol' Antique Shoppe."))}}
+ :layers [(assoc (texture "inside-castle/background.png") :x 0 :y 0 :baseline 0)
+ (assoc (texture "inside-castle/pedestal-overlay.png") :x 0 :y 0 :baseline 135)]
+ :entities {:game-player (assoc (texture "inside-castle/gameplayer.png") :x 266 :y 49 :baseline 191
+ :script (actions/get-script entities (do-game-player-dialogue entities))
+ :scripts {:wool (actions/get-script entities
+ (if (= :wool (get-in @entities [:state :current-riddle]))
+ (do (actions/update-state entities #(assoc % :current-riddle :balloon))
+ (actions/remove-item entities items/wool)
+ (actions/do-dialogue entities
+ :game-player "That's right! Now for your second riddle:"
+ :game-player "Filled with air, light as a feather,"
+ :game-player "If you want to keep it, best have a tether."))
+ (actions/talk entities :ego "He doesn't need it.")))
+ :balloon (actions/get-script entities
+ (if (= :balloon (get-in @entities [:state :current-riddle]))
+ (do (actions/update-state entities #(assoc % :current-riddle :frog-legs))
+ (actions/remove-item entities items/balloon)
+ (actions/do-dialogue entities
+ :game-player "That's right! Now for your third riddle:"
+ :game-player "Hippity-hop, I jump really far,"
+ :game-player "Now I'm dead, or at least a have a scar."))
+ (actions/talk entities :ego "He doesn't need it.")))
+ :frog-legs (actions/get-script entities
+ (if (= :frog-legs (get-in @entities [:state :current-riddle]))
+ (do (actions/update-state entities #(assoc % :current-riddle :done))
+
+ (actions/remove-item entities items/frog-legs)
+ (actions/do-dialogue entities
+ :game-player "Wow! That's right!"
+ :game-player "I guess I'm not the wisest person in Remington."
+ :game-player "You have earned my trophy.")
+ (actions/give entities items/trophy))
+ (actions/talk entities :ego "He doesn't need it.")))}
+ :anim nil
+ :talk game-player-talk)}
+ :collision "inside-castle/collision.png"
+ :scale-fn (utils/scaler-fn-from-image "inside-castle/scale.png" 0.25 1.00))))
diff --git a/desktop/src-common/advent/screens/rooms/inside_house.clj b/desktop/src-common/advent/screens/rooms/inside_house.clj
index fd708c19..cfd9159a 100644
--- a/desktop/src-common/advent/screens/rooms/inside_house.clj
+++ b/desktop/src-common/advent/screens/rooms/inside_house.clj
@@ -1,5 +1,6 @@
(ns advent.screens.rooms.inside-house
- (:require [advent.screens.rooms :as rooms]
+ (:require [advent.screens.items :as items]
+ [advent.screens.rooms :as rooms]
[advent.actions :as actions]
[advent.utils :as utils]
[clojure.zip :as zip]
@@ -14,16 +15,23 @@
(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)))]
- (rooms/make :interactions {:down-dir {:box [151 0 320 20]
+ (rooms/make :music :inside-fangald
+ :interactions {:down-dir {:box [151 0 320 20]
:script (actions/get-script entities
(actions/walk-to entities :ego [237 1])
(actions/transition-background entities :outside-house [262 88]))
:cursor :down}
- :wizard {:box [228 80 248 126]}}
+ :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."))}
+ }
: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 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 (doto 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
@@ -34,7 +42,7 @@
:x 265 :y 80 :baseline 240
:script (actions/get-script entities
(actions/remove-entity entities :flask)
- (actions/give entities :flask)
+ (actions/give entities items/flask-1)
(actions/do-dialogue entities :ego "Hey you think I could have this flask?"
:wizard "Sure.")))}
:collision "inside-house/collision.png"
diff --git a/desktop/src-common/advent/screens/rooms/outside_castle.clj b/desktop/src-common/advent/screens/rooms/outside_castle.clj
index 501fc791..da7814b4 100644
--- a/desktop/src-common/advent/screens/rooms/outside_castle.clj
+++ b/desktop/src-common/advent/screens/rooms/outside_castle.clj
@@ -1,5 +1,6 @@
(ns advent.screens.rooms.outside-castle
- (:require [advent.screens.rooms :as rooms]
+ (:require [advent.screens.items :as items]
+ [advent.screens.rooms :as rooms]
[advent.actions :as actions]
[advent.utils :as utils]
[clojure.zip :as zip]
@@ -14,22 +15,32 @@
(aget peddler-sheet 0 i)))
peddler-stand (animation 0.2 (for [i (flatten [(repeat 5 0) 6])]
(aget peddler-sheet 0 i)))]
- (rooms/make :interactions
+ (rooms/make :music :town-2
+ :interactions
{:right-dir {:box [300 40 320 140]
:script (actions/get-script
entities
(actions/walk-to entities :ego [310 80])
(actions/transition-background entities :outside-house [0 80]))
:cursor :right}
+ :door {:box [66 180 85 195]
+ :script (actions/get-script
+ entities
+ (actions/walk-to entities :ego [82 180])
+ (actions/transition-background entities :inside-castle [280 145])
+ (actions/walk-to entities :ego [245 90]))
+ :cursor :left}
:garden {:box [103 170 178 200]
:script (actions/get-script
entities
- (if ((get-in @entities [:state :inventory]) :carrot)
+ (if (actions/has-item? @entities items/carrot)
(actions/talk entities :ego "If I steal any more, I might get caught.")
(do
(actions/walk-to entities :ego [128 180])
- (actions/talk entities :ego "Hey! Carrots. No one will notice one missing.")
- (actions/give entities :carrot))))}
+ (actions/talk entities :ego "Hey! Carrots.")
+ (actions/play-animation entities :ego :squat)
+ (actions/talk entities :ego "No one will notice one missing.")
+ (actions/give entities items/carrot))))}
:peddler {:box [110 90 128 146]
:script (actions/get-script
entities
@@ -42,17 +53,20 @@
: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 useful books like this:"
- :peddler "'Checkers Mastery in Less Than 10 Seconds'"
- :ego "I sure am interested on that book on checkers."
- :peddler "An excellent selection! It is the choicest of checkers book you'll ever find."
- :peddler "This book will only set you back 75 sheckels."
+ :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 checkers books."))}}
+ :peddler "Then you won't have the choicest of balloons.")
+ (actions/give entities items/balloon))}}
: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
:talk peddler-talk :stand peddler-stand)
- :stand)}
+ :stand)
+ :steer (assoc (texture "outside-castle/steer.png" ) :x 203 :y 155 :baseline 80
+ :script (actions/get-script entities
+ (actions/talk entities :ego "That is one buff bull!")))}
:collision "outside-castle/collision.png"
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00))))
diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj
index 79e813a0..cfcd06e3 100644
--- a/desktop/src-common/advent/screens/rooms/outside_house.clj
+++ b/desktop/src-common/advent/screens/rooms/outside_house.clj
@@ -1,5 +1,6 @@
(ns advent.screens.rooms.outside-house
- (:require [advent.screens.rooms :as rooms]
+ (:require [advent.screens.items :as items]
+ [advent.screens.rooms :as rooms]
[advent.actions :as actions]
[advent.utils :as utils]
[clojure.zip :as zip]
@@ -19,7 +20,7 @@
(< (dist-to-sheep entities) 45))
(defn wizard-dialogue [entities]
- (actions/do-dialogue entities :ego "Hello there Mr. Fangald!" :wizard "Oh no, not you again!")
+ (actions/do-dialogue entities :ego "Hello there Gandarf!" :wizard "Oh no, not you again!")
(actions/present-choices entities
{:choices ["What do you mean, \"Not you again?\""
{:run #(actions/respond entities % :wizard "I mean, you've wrecked my life and I never want to see you again.")
@@ -103,10 +104,10 @@
:wizard "While your goal sounds noble, no amount of bizarre conversation tree searching will earn my respect."
:wizard "Now please leave.")
(actions/transition-background entities :outside-house [262 88]))}]}]}]}
- "You're not happy to see me, Mr. Fangald?"
+ "You're not happy to see me, Gandarf?"
{:run #(actions/respond entities % :wizard "Of course not, you little brat. You've made my life a living hell!")
:choices #(-> % zip/left)}
- "Good bye, Mr. Fangald!"
+ "Goodbye, Gandarf!"
{:run #(do
(actions/respond entities % :wizard "Now scram!")
(actions/transition-background entities :outside-house [262 88]))}]}))
@@ -115,14 +116,16 @@
sheep-walk-sheet (texture! (texture "outsidehouse/sheep-walk.png") :split 33 21)
sheep-stand (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 9 10 (repeat 25 11) (repeat 15 12)])]
(aget sheep-stand-sheet 0 i)))
- sheep-walk (animation 0.15 (for [i (range 6)]
+ sheep-walk (animation 0.05 (for [i (range 6)]
(aget sheep-walk-sheet 0 i)))]
- (rooms/make :interactions
+ (rooms/make :music :town-2
+ :interactions
{:door {:box [258 100 281 160]
:script (actions/get-script
entities
- (actions/walk-to entities :ego [262 88])
+ (actions/walk-to entities :ego [267 90])
(actions/talk entities :ego (str "Anyone home?"))
+ (actions/play-animation entities :ego :reach)
(actions/transition-background entities :inside-house [237 0])
(if (get-in @entities [:state :convinced-wizard?])
(actions/talk entities :wizard (str "Oh, hello there boy."))
@@ -162,27 +165,30 @@
:box [38 160 71 181]
:script (actions/get-script
entities
-
- (if ((get-in @entities [:state :inventory]) :wool)
+ (if (actions/has-item? @entities items/wool)
(actions/talk entities :ego "The sheep has given me enough wool.")
(if (is-sheep-close? @entities)
- (do (actions/walk-to entities :ego ego-sheep-loc)
- (actions/give entities :wool)
+ (do (actions/walk-to entities :ego ego-sheep-loc :face :left)
+ (actions/play-animation entities :ego :reach)
+ (actions/give entities items/wool)
(actions/talk entities :ego "I guess her wool is shedding."))
(actions/talk entities :ego "She's too far away for me to pet her."))))
:scripts {:wool (actions/get-script entities
(actions/talk entities :ego "She doesn't need it back."))
:carrot (actions/get-script entities
- (actions/walk-to entities :ego ego-sheep-loc)
+ (actions/walk-to entities :ego ego-sheep-loc :face :left)
(actions/talk entities :ego "Come on girl, get the carrot!")
(actions/walk-straight-to entities :sheep [95 150]))
- :flask (actions/get-script entities
+ :flask-1 (actions/get-script entities
(if (is-sheep-close? @entities)
- (do (actions/walk-to entities :ego ego-sheep-loc)
- (actions/give entities :flask-with-contents)
+ (do (actions/walk-to entities :ego ego-sheep-loc :face :left)
+ (actions/play-animation entities :ego :reach)
+ (actions/remove-item entities items/flask-1)
+ (actions/give entities items/flask-1-with-milk)
(actions/talk entities :ego "Sheeps milk."))
- (actions/talk entities :ego "She's too far away.")))}
+ (actions/talk entities :ego "She's too far away.")))
+ items/flask-1-with-mushrooms (items/make-cream-of-mushroom)}
:left {:walk (utils/flip sheep-walk)
:stand (utils/flip sheep-stand)}
:right {:walk sheep-walk
diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj
index 5c9c8a5e..9f2ee1ff 100644
--- a/desktop/src-common/advent/screens/scene.clj
+++ b/desktop/src-common/advent/screens/scene.clj
@@ -11,8 +11,10 @@
[advent.zone :as zone]
[advent.utils :as utils]
[advent.screens.rooms :as rooms]
+ [advent.screens.items :as items]
[advent.screens.rooms.outside-house :as rooms.outside-house]
[advent.screens.rooms.inside-house :as rooms.inside-house]
+ [advent.screens.rooms.inside-castle :as rooms.inside-castle]
[advent.screens.rooms.behind-house :as rooms.behind-house]
[advent.screens.rooms.outside-castle :as rooms.outside-castle]
[advent.screens.rooms.cat-tree :as rooms.cat-tree]
@@ -27,7 +29,7 @@
(def default-interaction
{:get-script (fn [cursor [x y]] (if (= :main cursor)
(actions/get-script entities
- (actions/walk-to entities :ego [x y] true))
+ (actions/walk-to entities :ego [x y] :can-skip? true))
(actions/get-script entities
(actions/talk entities :ego "I don't know what to do with that."))))})
@@ -38,7 +40,7 @@
(get-in entities [:room :interactions]))))
(defn open-inventory [screen entities]
- (run! inventory-screen :show-screen :items (get-in entities [:state :inventory]))
+ (screen! inventory-screen :show-screen :items (get-in entities [:state :inventory]))
(assoc-in entities [:state :active?] false))
@@ -46,7 +48,6 @@
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
(if ((:mouse-in? (:inventory entities)) x y)
(open-inventory screen entities)
-
(let [interaction (first (filter #((:mouse-in? %) entities x y)
(get-in entities [:room :interactions])))
interacting-entity (first (filter #(and (:mouse-in? %)
@@ -78,24 +79,48 @@
(let [player-sheet (texture! (texture "player.png") :split 18 36)
talk-sheet (texture! (texture "ego/talk.png") :split 18 36)
stand-sheet (texture! (texture "ego/stand.png") :split 18 36)
+ 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)
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 ])]
(texture (aget stand-sheet 0 i))))
talk-anim (animation 0.2 (for [i (range 8)]
(texture (aget talk-sheet 0 i))))
+ squat-anim (animation 0.05 (for [i [0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 2 1] ]
+ (texture (aget squat-sheet 0 i))))
+ 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))))
ego {:right {:walk walk-right
:stand stand-anim
- :talk talk-anim}
+ :talk talk-anim
+ :squat squat-anim
+ :reach reach-anim
+ :cat-toy cat-toy-anim}
:left {:walk (utils/flip walk-right)
:stand (utils/flip stand-anim)
- :talk (utils/flip talk-anim)}
+ :talk (utils/flip talk-anim)
+ :squat (utils/flip squat-anim)
+ :reach (utils/flip reach-anim)
+ :cat-toy (utils/flip cat-toy-anim)}
:baseline 95
:facing :right
:origin-x 9
:origin-y 0
:scaled true
+ #_:mouse-in? #_(fn [entities x y]
+ (let [{entity-x :x entity-y :y region :object} (get-in entities [:room :entities :ego])
+ width (.getRegionWidth region)
+ height (.getRegionHeight region)]
+
+ ((zone/box entity-x entity-y (+ entity-x width) (+ entity-y height)) x y)))
+ #_:get-script #_(fn [cursor [x y]]
+ (case cursor
+ items/flask-with-cream-of-mushroom (actions/get-script entities (actions/talk entities :ego "Yuck. I filled it with backwash."))))
:x 150 :y 95
:id "ego"}]
(actions/start-animation screen
@@ -117,45 +142,57 @@
(defn update-cursor [screen {{:keys [current override last]} :cursor :as entities}]
- (when-not (= (or override current)
- last)
- (input! :set-cursor-image (utils/cursor "cursor.png" (or override current)) 0 0))
- (assoc-in entities [:cursor :last] (or override current)))
+ (let [new-current (or override current)]
+ (when-not (= new-current
+ last)
+ (input! :set-cursor-image (utils/cursor "cursor.png" (or (:cursor new-current) new-current)) 0 0))
+ (assoc-in entities [:cursor :last] new-current)))
(defn animate [entity screen]
(merge entity (animation->texture (update-in screen [:total-time] #(- % (:anim-start entity)))
(:anim entity))))
+
+(defn play-sound [snd]
+ (music! snd :play))
+
+(defn make-music [r]
+ (doto (music r) (music! :set-looping true)))
+
(defscreen scene
:on-show
(fn [screen entities]
- (update! screen :renderer (stage) :camera (orthographic))
- (let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
- music (sound "town-music.mp3")
- ;; _ (sound! music :loop 0.80)
- rooms {:inside-house (rooms.inside-house/make screen)
- :outside-house (rooms.outside-house/make screen)
- :behind-house (rooms.behind-house/make screen)
- :cat-tree (rooms.cat-tree/make screen)
- :outside-castle (rooms.outside-castle/make screen)}]
- {:rooms rooms
- :state {:object nil
- :active? true
- :inventory (sorted-set)}
- :actions {:object nil
- :channel (chan)
- :current nil
- :started? false}
- :cursor {:id "cursor"
- :current :main
- :last :main
- :override nil}
- :room (assoc-in (:outside-house rooms)
- [:entities :ego] (get-ego screen))
- :inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000
- :mouse-in? (zone/box 278 0 320 42))
- :fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)}))
+ (let [screen (assoc screen :total-time 0)]
+ (update! screen :renderer (stage) :camera (orthographic))
+ (let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
+ rooms {:inside-house (rooms.inside-house/make screen)
+ :outside-house (rooms.outside-house/make screen)
+ :behind-house (rooms.behind-house/make screen)
+ :cat-tree (rooms.cat-tree/make screen)
+ :inside-castle (rooms.inside-castle/make screen)
+ :outside-castle (rooms.outside-castle/make screen)}]
+ {:rooms rooms
+ :musics {:object nil
+ :town-1 (make-music "town-music-1.ogg")
+ :town-2 (doto (make-music "town-music-2.ogg") play-sound)
+ :inside-fangald (make-music "inside-fangald.ogg")}
+ :state {:object nil
+ :active? true
+ :inventory []}
+ :actions {:object nil
+ :channel (chan)
+ :current nil
+ :started? false}
+ :cursor {:id "cursor"
+ :current :main
+ :last :main
+ :override nil}
+ :room (assoc-in (:outside-house rooms)
+ [:entities :ego] (get-ego screen))
+ :inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000
+ :mouse-in? (zone/box 278 0 320 42))
+ :fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)})))
:on-render
(fn [screen [entities]]
@@ -184,7 +221,7 @@
(assoc-in entities [:cursor :override] (:cursor mouse-override))
(assoc-in entities [:cursor :override] nil)))))
- :on-touch-down (fn [screen [entities]]
+ :on-touch-up (fn [screen [entities]]
(when (get-in entities [:state :active?])
(if (= (button-code :right)
(:button screen))
diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj
index f4d5c165..ed51c75c 100644
--- a/desktop/src-common/advent/utils.clj
+++ b/desktop/src-common/advent/utils.clj
@@ -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])
+(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :stool :stick :cat-toy :balloon :frog-legs])
(defn cursor [filename which]
(let [scale 2
@@ -38,12 +38,22 @@
(defn scaler-fn-with-baseline [baseline minimum-size & [maximum-size]]
(let [maximum-size (or maximum-size 1.0)]
- (fn [y]
+ (fn [[_ y]]
(if (< y baseline) maximum-size
(let [percent-complete (- 1.0 (/ (- y baseline) (- +screen-height+ baseline)))
range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)]
range)))))
+(defn scaler-fn-from-image [image minimum-size maximum-size]
+ (let [image (pixmap image)
+ maximum-size (or maximum-size 1.0)]
+ (fn [[x y]]
+ (let [percent-complete (-> image
+ (pixmap! :get-pixel x (- 240 y))
+ color
+ (.r))]
+ (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)))))
+
(defn dist [x1 y1 x2 y2]
(let [dx (- x1 x2)
dy (- y1 y2)]