music and latest version.

This commit is contained in:
2014-11-04 12:50:48 -08:00
parent f2bcae0d45
commit 9a331cba07
4 changed files with 45 additions and 41 deletions

View File

@@ -207,7 +207,7 @@
scale-fn (get-in entities [:room :scale-fn]) scale-fn (get-in entities [:room :scale-fn])
scale (scale-fn [target-x target-y]) scale (scale-fn [target-x target-y])
height (* scale 36)] 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) :x (get-in entities [:room :entities target-id :x]) :y (+ (get-in entities [:room :entities target-id :y]) height)
:target-id target-id :target-id target-id
:scale scale) :scale scale)
@@ -221,7 +221,7 @@
(get-text-duration text))) (get-text-duration text)))
(terminate [this screen entities] (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? (if stop?
(stop screen entities target-id) (stop screen entities target-id)
entities)) entities))
@@ -251,8 +251,8 @@
dialogue-choices (filter first (partition 2 (:choices node)))] dialogue-choices (filter first (partition 2 (:choices node)))]
(run-action entities (run-action entities
(begin [this screen entities] (begin [this screen entities]
(run! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %)) (screen! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %))
(run! @(resolve 'advent.screens.scene/scene) :on-deactivate) (screen! @(resolve 'advent.screens.scene/scene) :on-deactivate)
entities) entities)
(continue [this screen entities] entities) (continue [this screen entities] entities)
@@ -260,7 +260,7 @@
(done? [this screen entities] (not (nil? @selected-index))) (done? [this screen entities] (not (nil? @selected-index)))
(terminate [this screen entities] (terminate [this screen entities]
(run! @(resolve 'advent.screens.scene/scene) :on-reactivate) (screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
entities) entities)
(can-skip? [this screen entities] (can-skip? [this screen entities]
false)) false))
@@ -368,9 +368,9 @@
(when (not= new-music old-music) (when (not= new-music old-music)
(doseq [[k v] (:musics entities) (doseq [[k v] (:musics entities)
:when (and v (not= new-music k))] :when (and v (not= new-music k))]
(sound! v :stop)) (music! v :stop))
(when new-music (when new-music
(sound! (get-in entities [:musics new-music]) :loop 0.30))) (music! (get-in entities [:musics new-music]) :play)))
(-> entities (-> entities
(update-in [:room :entities :ego] #(jump-to screen entities % [x y]))))) (update-in [:room :entities :ego] #(jump-to screen entities % [x y])))))

View File

@@ -15,7 +15,7 @@
(defn close [entities] (defn close [entities]
(run! @(resolve 'advent.screens.scene/scene) :on-reactivate) (screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
(-> entities (-> entities
(assoc :shown? false) (assoc :shown? false)
(assoc :start-showing? false))) (assoc :start-showing? false)))
@@ -90,7 +90,7 @@
current-cursor (get-in room-entities [:cursor :current])] current-cursor (get-in room-entities [:cursor :current])]
(if highlighted-item (if highlighted-item
(if (= :main current-cursor) (if (= :main current-cursor)
(run! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item) (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))] (when-let [interaction-script ((or (:scripts highlighted-item) (constantly nil)) (:value current-cursor))]
(interaction-script room-entities) (interaction-script room-entities)
(close entities))) (close entities)))

View File

@@ -31,7 +31,7 @@
:layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0) :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/desk.png") :x 0 :y 0 :baseline 200)
(assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)] (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) :left {:talk (utils/flip wizard-talk)
:stand (utils/flip wizard-stand)} :stand (utils/flip wizard-stand)}
:right {:talk wizard-talk :right {:talk wizard-talk

View File

@@ -40,7 +40,7 @@
(get-in entities [:room :interactions])))) (get-in entities [:room :interactions]))))
(defn open-inventory [screen entities] (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)) (assoc-in entities [:state :active?] false))
@@ -155,40 +155,44 @@
(:anim entity)))) (:anim entity))))
(defn play-sound [snd] (defn play-sound [snd]
(sound! snd :loop 0.3)) (music! snd :play))
(defn make-music [r]
(doto (music r) (music! :set-looping true)))
(defscreen scene (defscreen scene
:on-show :on-show
(fn [screen entities] (fn [screen entities]
(update! screen :renderer (stage) :camera (orthographic)) (let [screen (assoc screen :total-time 0)]
(let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0) (update! screen :renderer (stage) :camera (orthographic))
rooms {:inside-house (rooms.inside-house/make screen) (let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
:outside-house (rooms.outside-house/make screen) rooms {:inside-house (rooms.inside-house/make screen)
:behind-house (rooms.behind-house/make screen) :outside-house (rooms.outside-house/make screen)
:cat-tree (rooms.cat-tree/make screen) :behind-house (rooms.behind-house/make screen)
:inside-castle (rooms.inside-castle/make screen) :cat-tree (rooms.cat-tree/make screen)
:outside-castle (rooms.outside-castle/make screen)}] :inside-castle (rooms.inside-castle/make screen)
{:rooms rooms :outside-castle (rooms.outside-castle/make screen)}]
:musics {:object nil {:rooms rooms
:town-1 (sound "town-music.mp3") :musics {:object nil
:town-2 (doto (sound "town-music-2.mp3") play-sound) :town-1 (make-music "town-music-1.ogg")
:inside-fangald (sound "inside-fangald.mp3")} :town-2 (doto (make-music "town-music-2.ogg") play-sound)
:state {:object nil :inside-fangald (make-music "inside-fangald.ogg")}
:active? true :state {:object nil
:inventory []} :active? true
:actions {:object nil :inventory []}
:channel (chan) :actions {:object nil
:current nil :channel (chan)
:started? false} :current nil
:cursor {:id "cursor" :started? false}
:current :main :cursor {:id "cursor"
:last :main :current :main
:override nil} :last :main
:room (assoc-in (:outside-house rooms) :override nil}
[:entities :ego] (get-ego screen)) :room (assoc-in (:outside-house rooms)
:inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000 [:entities :ego] (get-ego screen))
:mouse-in? (zone/box 278 0 320 42)) :inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)})) :mouse-in? (zone/box 278 0 320 42))
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 0)})))
:on-render :on-render
(fn [screen [entities]] (fn [screen [entities]]