diff --git a/desktop/resources/inside-castle/hands-1.png b/desktop/resources/inside-castle/hands-1.png new file mode 100644 index 00000000..90780529 Binary files /dev/null and b/desktop/resources/inside-castle/hands-1.png differ diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index d65c849f..d9a36ea5 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -394,6 +394,31 @@ (can-skip? [this screen entities] false))) +(defn transition-music + ([entities new-music] + (transition-music entities (get-in @entities [:room :music]) new-music)) + ([entities old-music new-music] + (let [current-volume (atom 1.0)] + (run-action entities + (begin [this screen entities] + entities) + + (continue [this screen entities] + (let [new-volume (swap! current-volume #(- % 0.01))] + (music! (get-in entities [:musics old-music]) :set-volume new-volume)) + entities) + + (done? [this screen entities] + (>= 0.1 @current-volume)) + + (terminate [this screen entities] + (music! (get-in entities [:musics old-music]) :stop) + (music! (get-in entities [:musics new-music]) :set-volume 1.0) + (music! (get-in entities [:musics new-music]) :play) + entities) + (can-skip? [this screen entities] + false))))) + (defn transition-background [entities new-background [x y]] (let [old-music (get-in @entities [:room :music]) new-music (get-in @entities [:rooms new-background :music]) diff --git a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj index 00609af7..25d076de 100644 --- a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj +++ b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj @@ -9,6 +9,12 @@ [play-clj.utils :refer :all] [play-clj.g2d :refer :all])) +(defn make-fight-entity [] + (assoc (texture "inside-castle/fight-1.png") + :x 0 + :y 0 + :baseline 1000)) + (defn do-warrior-dialogue [entities] (actions/walk-to entities :ego [150 45] :face :left) (actions/talk entities :ego "Hey guys!") @@ -43,11 +49,13 @@ (actions/do-dialogue entities :ego "One sec.") (actions/play-animation entities :ego :grow) (actions/do-dialogue entities - :warriors "[Todo animation here]" :warriors "Congratulations young master. Thou art worthy in might." :warriors "Take my medal of strength.") (actions/give entities :medal)) (do + + (actions/transition-music entities :town-2 :fight) + (actions/add-entity entities :fight (get-in @entities [:room :fight])) (actions/do-dialogue entities :warriors "[Todo animation here]" :warriors "You lost, young master. Go hitherto, unto thy gym."))))} @@ -120,7 +128,8 @@ ladder-guard-sheet (texture! (texture "inside-cafeteria/ladder-guard.png") :split 37 87) ladder-guard-stand (animation 0.1 [(aget ladder-guard-sheet 0 0)]) ladder-guard-talk (animation 0.2 (for [i [0 0 0 0 1 0 0 1]] - (aget ladder-guard-sheet 0 i)))] + (aget ladder-guard-sheet 0 i))) + ] (rooms/make :music :town-1 :interactions {:right-dir {:box [300 0 320 120] @@ -132,7 +141,8 @@ :cursor :right} } :layers [(assoc (texture "inside-cafeteria/background.png") :x 0 :y 0 :baseline 0)] - :entities {:warriors (actions/start-animation screen (assoc (animation->texture screen warriors-stand) :x 5 :y 9 :baseline 180 + :entities { + :warriors (actions/start-animation screen (assoc (animation->texture screen warriors-stand) :x 5 :y 9 :baseline 180 :left {:stand (utils/flip warriors-stand) :talk (utils/flip warriors-stand)} @@ -152,6 +162,7 @@ :script (actions/get-script entities (actions/talk entities :ladder-guard "Do not toucheth, young sire.")))} :collision "inside-cafeteria/collision.png" + :fight (make-fight-entity) :scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.50) :apply-state (fn [entities] (as-> entities entities diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index e62895c2..0e31842f 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -1,4 +1,5 @@ (ns advent.screens.scene + (:refer-clojure :exclude [load]) (:require [play-clj.core :refer :all] [play-clj.ui :refer :all] [play-clj.utils :refer :all] @@ -245,7 +246,8 @@ :inside-antique (make-music "inside-antique.ogg") :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")} + :inside-fangald (make-music "inside-fangald.ogg") + :fight (make-music "megaboss.mp3")} :state (get-state) :actions {:object nil :channel (chan) diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index e3db4a0d..726cdd61 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -1,4 +1,5 @@ (ns advent.utils + (:refer-clojure :exclude [load]) (:require [play-clj.core :refer :all] [play-clj.ui :refer :all] [play-clj.utils :refer :all]