diff --git a/desktop/blergh.edn b/desktop/blergh.edn new file mode 100644 index 00000000..e54d9fee --- /dev/null +++ b/desktop/blergh.edn @@ -0,0 +1 @@ +{:active? true, :convinced-wizard? true, :time :day, :inventory [:ladder :glass-eye :recipe :grass :medal :kiss :trophy :flask-1-strength :sword], :wizard-left? false, :clues #{}, :current-riddle :wool, :last-room :space, :wants-toy true, :mints-eaten 0, :object nil, :obtained-items #{:kiss :medal :sword :flask-1 :grass :ladder :trophy}} \ No newline at end of file diff --git a/desktop/resources/ego/Untitled.png b/desktop/resources/ego/Untitled.png index fd2e23ae..e4558c5c 100644 Binary files a/desktop/resources/ego/Untitled.png and b/desktop/resources/ego/Untitled.png differ diff --git a/desktop/resources/ego/pant.png b/desktop/resources/ego/pant.png new file mode 100644 index 00000000..6e1c778e Binary files /dev/null and b/desktop/resources/ego/pant.png differ diff --git a/desktop/resources/ego/pant.pxa/0.pxi b/desktop/resources/ego/pant.pxa/0.pxi new file mode 100644 index 00000000..2071299c Binary files /dev/null and b/desktop/resources/ego/pant.pxa/0.pxi differ diff --git a/desktop/resources/ego/pant.pxa/1.pxi b/desktop/resources/ego/pant.pxa/1.pxi new file mode 100644 index 00000000..2b11eb93 Binary files /dev/null and b/desktop/resources/ego/pant.pxa/1.pxi differ diff --git a/desktop/resources/ego/pant.pxa/CelData.plist b/desktop/resources/ego/pant.pxa/CelData.plist new file mode 100644 index 00000000..29c78f8b --- /dev/null +++ b/desktop/resources/ego/pant.pxa/CelData.plist @@ -0,0 +1,14 @@ + + + + + + duration + 1 + + + duration + 1 + + + diff --git a/desktop/resources/ego/swing.png b/desktop/resources/ego/swing.png index f0175f3d..bc93ff2c 100644 Binary files a/desktop/resources/ego/swing.png and b/desktop/resources/ego/swing.png differ diff --git a/desktop/resources/ego/swing.pxa/0.pxi b/desktop/resources/ego/swing.pxa/0.pxi index 81277d13..38388afc 100644 Binary files a/desktop/resources/ego/swing.pxa/0.pxi and b/desktop/resources/ego/swing.pxa/0.pxi differ diff --git a/desktop/resources/ego/swing.pxa/1.pxi b/desktop/resources/ego/swing.pxa/1.pxi index 4bcd068d..982b4e35 100644 Binary files a/desktop/resources/ego/swing.pxa/1.pxi and b/desktop/resources/ego/swing.pxa/1.pxi differ diff --git a/desktop/resources/ego/swing.pxa/2.pxi b/desktop/resources/ego/swing.pxa/2.pxi index 59d79827..a2e19423 100644 Binary files a/desktop/resources/ego/swing.pxa/2.pxi and b/desktop/resources/ego/swing.pxa/2.pxi differ diff --git a/desktop/resources/ego/swing.pxa/3.pxi b/desktop/resources/ego/swing.pxa/3.pxi index e73eaa8c..0a38b33f 100644 Binary files a/desktop/resources/ego/swing.pxa/3.pxi and b/desktop/resources/ego/swing.pxa/3.pxi differ diff --git a/desktop/resources/ego/swing.pxa/4.pxi b/desktop/resources/ego/swing.pxa/4.pxi index e2f4ce92..4e243321 100644 Binary files a/desktop/resources/ego/swing.pxa/4.pxi and b/desktop/resources/ego/swing.pxa/4.pxi differ diff --git a/desktop/resources/ego/swing.pxa/5.pxi b/desktop/resources/ego/swing.pxa/5.pxi new file mode 100644 index 00000000..31ba94b3 Binary files /dev/null and b/desktop/resources/ego/swing.pxa/5.pxi differ diff --git a/desktop/resources/ego/swing.pxa/6.pxi b/desktop/resources/ego/swing.pxa/6.pxi new file mode 100644 index 00000000..208a8471 Binary files /dev/null and b/desktop/resources/ego/swing.pxa/6.pxi differ diff --git a/desktop/resources/ego/swing.pxa/7.pxi b/desktop/resources/ego/swing.pxa/7.pxi new file mode 100644 index 00000000..b9589a02 Binary files /dev/null and b/desktop/resources/ego/swing.pxa/7.pxi differ diff --git a/desktop/resources/ego/swing.pxa/CelData.plist b/desktop/resources/ego/swing.pxa/CelData.plist index 1ff35422..3cc9cf5c 100644 --- a/desktop/resources/ego/swing.pxa/CelData.plist +++ b/desktop/resources/ego/swing.pxa/CelData.plist @@ -22,5 +22,17 @@ duration 1 + + duration + 1 + + + duration + 1 + + + duration + 1 + diff --git a/desktop/resources/white.png b/desktop/resources/white.png new file mode 100644 index 00000000..8752cfba Binary files /dev/null and b/desktop/resources/white.png differ diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index e4069050..71510dcf 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -116,7 +116,7 @@ (update-in entities [:room :entities target-id] (comp #(start-animation screen % :stand) (if face #(assoc % :facing face) identity)))) -(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir]}] +(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir stop?]}] (let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id]) final-x (int final-x) final-y (int final-y) @@ -155,7 +155,9 @@ (< (utils/dist final-x final-y from-x from-y) 1))) (terminate [this screen entities] - (stop screen entities target-id :face face)) + (if (or (nil? stop?) stop?) + (stop screen entities target-id :face face) + entities)) (can-skip? [this screen entities] false)))) diff --git a/desktop/src-common/advent/screens/rooms/space.clj b/desktop/src-common/advent/screens/rooms/space.clj index cb1c9a4d..0a175940 100644 --- a/desktop/src-common/advent/screens/rooms/space.clj +++ b/desktop/src-common/advent/screens/rooms/space.clj @@ -10,6 +10,7 @@ [play-clj.core :refer :all] [play-clj.ui :refer :all] [play-clj.utils :refer :all] + [play-clj.math :refer :all] [play-clj.g2d :refer :all])) (defn taunt [screen entities] @@ -23,6 +24,88 @@ "Pick up your weapon and fight!"]))) entities)) nil) +(defn start-swing-if-necessary [screen e] + (if (and (not= (:anim e) :swing) + (> (:x e) 190)) + (actions/start-animation screen e :swing) + e)) + +(defn start-fade-if-necessary [e screen] + (if (and (nil? (get-in e [:tweens :flash])) + (< (get-in e [:room :entities :ego :y]) 100)) + (assoc-in e [:tweens :flash] (utils/tween :flash screen [:white-fade :opacity] 0.0 1.0 0.5 :power 3.0)) + e)) + +(defn swing-at-blergh [entities] + (let [jump-path (bezier (map #(apply vector-2* %) [[15 45] [110 145] [195 180]])) + swing-path (bezier (map #(apply vector-2* %) [[195 180] [205 45]])) + jump-dist (utils/dist 15 45 205 45) + speed 190.0 + jump-duration (/ jump-dist speed) + swing-dist (utils/dist 195 180 205 45) + swing-duration (/ swing-dist (* speed 1.5))] + (actions/run-action entities + (begin [this screen entities] + (-> entities + (update-in [:room :entities :ego] + #(actions/start-animation screen % :jump)) + (assoc-in [:tweens :jump-pos] (utils/tween :jump-pos screen [:room :entities :ego :move-pct] 0.0 1.0 jump-duration :power 2)))) + + (continue [this screen entities] + (let [v (vector-2 0 0) + a (bezier! jump-path :value-at v (get-in entities [:room :entities :ego :move-pct] 0.0))] + (update-in entities [:room :entities :ego] #(assoc % :x (vector-2! v :x) :y (vector-2! v :y))))) + + (done? [this screen entities] + (= (get-in entities [:room :entities :ego :move-pct]) 1.0)) + + (terminate [this screen entities] + (assoc-in entities [:room :entities :ego :move-pct] 0.0)) + (can-skip? [this screen entities] + false)) + + (actions/run-action entities + (begin [this screen entities] + + (-> entities + (update-in [:room :entities :ego] + #(actions/start-animation screen % :swing)) + (assoc-in [:tweens :swing-pos] (utils/tween :swing-pos screen [:room :entities :ego :move-pct] 0.0 1.0 swing-duration :power 10)))) + + (continue [this screen entities] + (let [v (vector-2 0 0) + a (bezier! swing-path :value-at v (get-in entities [:room :entities :ego :move-pct] 0.0))] + (-> entities + (start-fade-if-necessary screen) + (update-in [:room :entities :ego] #(assoc % :x (vector-2! v :x) :y (vector-2! v :y)))))) + + (done? [this screen entities] + (= (get-in entities [:room :entities :ego :move-pct]) 1.0)) + + (terminate [this screen entities] + (-> entities + (assoc-in [:room :entities :ego :move-pct] 0.0) + (update-in [:room :entities :ego] #(actions/start-animation screen % :pant)))) + (can-skip? [this screen entities] + + false)) + (actions/run-action entities + (begin [this screen entities] + (assoc-in entities [:tweens :flash] (utils/tween :flash screen [:white-fade :opacity] 1.0 0.0 3.0 :power 2.0))) + + (continue [this screen entities] + entities) + + (done? [this screen entities] + (nil? (get-in entities [:tweens :flash]))) + + (terminate [this screen entities] + entities) + (can-skip? [this screen entities] + false)))) + + + (defn make [screen] (let [blergh-stand (texture "space/blergh-stand.png") blergh-talk (texture "space/blergh-talk.png") @@ -47,8 +130,9 @@ :talk-color (color 0.95 0.4 0.2 1.0) :script (actions/get-script entities (actions/do-dialogue entities :blergh "Come on! Try and hit me!")) :scripts {:sword (actions/get-script entities - (actions/walk-straight-to entities :ego [205 45]) - (actions/play-animation entities :ego :swing) + #_(actions/walk-straight-to entities :ego [205 45] :anim :jump :stop? false :speed 3.0) + (swing-at-blergh entities) + #_(actions/play-animation entities :ego :swing) (actions/do-dialogue entities :blergh "Ha ha ha! Is that the best you can do?" :blergh "Take this!") (actions/play-animation entities :blergh :swing) @@ -56,8 +140,8 @@ (actions/do-dialogue entities :ego "Ouch!" :blergh "My turn.") - (common/go-to-jail entities) - (actions/do-dialogue entities :ego "Hey!" + #_(common/go-to-jail entities) + #_(actions/do-dialogue entities :ego "Hey!" :ego "What's going on? I was just about to teach Blergh a lesson!")) :magic-slingshot (actions/get-script entities (actions/do-dialogue entities diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 96af308f..0cb21139 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -176,12 +176,14 @@ grow (animation 0.1 (for [i [0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 3 0 0 0 0 3 0 0 0 3 3 0 0 0 2 2 0 0 2 0 0 2 0 2 0 2 0 2 0 2 0 2 3 2 3 2 3 2 3 2 4 3 4 3 4 3 4]] (texture (aget grow-sheet 0 i)))) hold-up-to-window (utils/make-anim "ego/hold-up-to-window.png" [18 36] 0.1 [0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 1 0 0 0 0 0 0]) - swing (utils/make-anim "ego/swing.png" [36 36] 0.05 (flatten [[0 0 0 1 2 3 3 3 3 ]])) + jump (utils/make-anim "ego/swing.png" [36 75] 0.2 (flatten [[1 2]])) + swing (utils/make-anim "ego/swing.png" [36 75] 0.145 (flatten [[3 4 5 6 7 ]])) grow-talk (utils/make-anim "ego/grow-talk.png" [18 36] 0.2 (range 2)) get-sick (animation 0.3 (map (partial get [(aget talk-sheet 0 0 ) (texture "ego/get-sick.png")]) [0 1 1 1 1 1 1 1 1 1 1 1]) ) spear (utils/make-anim "ego/spear.png" [18 100] 0.2 [0 1 2 3 2 3 2 3 2 3 2 1 0]) crowbar (utils/make-anim "ego/crowbar.png" [36 36] 0.1 [0 0 0 1 1 2 2 2 2 2 3 2 3 2 3 2 3 2 3 3 3 1 1 0 0 0]) shoot (utils/make-anim "ego/shoot.png" [24 36] 0.075 [0 0 0 1 1 2 2 2 2 2 2 2 2 3 4 5 4]) + pant (utils/make-anim "ego/pant.png" [31 36] 0.5 [0 1]) ego {:right {:walk walk-right :stand stand-anim @@ -202,12 +204,14 @@ :reach-up reach-up :reach-down reach-down :reach-start reach-start + :jump jump :reach-stop reach-stop :shoot shoot [:fire 1] fire-1-anim [:fire 2] fire-2-anim [:fire 3] fire-3-anim - :spear spear} + :spear spear + :pant pant} :left {:walk (utils/flip walk-right) :stand (utils/flip stand-anim) :talk (utils/flip talk-anim) @@ -230,7 +234,8 @@ [:fire 1] (utils/flip fire-1-anim) [:fire 2] (utils/flip fire-2-anim) [:fire 3] (utils/flip fire-3-anim) - :spear (utils/flip spear)} + :spear (utils/flip spear) + :pant (utils/flip pant)} :baseline (- 240 (last start-pos)) :facing :right :origin-x 9 @@ -402,7 +407,11 @@ :scale-y 20 :baseline 9500 :opacity 0.0) - + :white-fade (assoc (texture "white.png") + :scale-x 20 + :scale-y 20 + :baseline 9500 + :opacity 0.0) :actions {:object nil :channel (chan) :current nil