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 (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)
@@ -221,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))
@@ -251,8 +251,8 @@
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)
@@ -260,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))
@@ -368,9 +368,9 @@
(when (not= new-music old-music)
(doseq [[k v] (:musics entities)
:when (and v (not= new-music k))]
(sound! v :stop))
(music! v :stop))
(when new-music
(sound! (get-in entities [:musics new-music]) :loop 0.30)))
(music! (get-in entities [:musics new-music]) :play)))
(-> entities
(update-in [:room :entities :ego] #(jump-to screen entities % [x y])))))

View File

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

View File

@@ -31,7 +31,7 @@
: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

View File

@@ -40,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))
@@ -155,40 +155,44 @@
(:anim entity))))
(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
:on-show
(fn [screen entities]
(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 (sound "town-music.mp3")
:town-2 (doto (sound "town-music-2.mp3") play-sound)
:inside-fangald (sound "inside-fangald.mp3")}
: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)}))
(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]]