added concept of different background musics.
This commit is contained in:
@@ -360,9 +360,17 @@
|
||||
(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))]
|
||||
(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))]
|
||||
(sound! v :stop))
|
||||
(when new-music
|
||||
(sound! (get-in entities [:musics new-music]) :loop 0.30)))
|
||||
(-> entities
|
||||
(update-in [:room :entities :ego] #(jump-to screen entities % [x y])))))
|
||||
|
||||
|
||||
@@ -10,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
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -92,7 +92,8 @@
|
||||
(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 :interactions
|
||||
(rooms/make :music :town-1
|
||||
:interactions
|
||||
{:right-door {:box [286 140 306 160]
|
||||
:cursor :right
|
||||
:script (actions/get-script entities
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
(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]))
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
(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
|
||||
|
||||
@@ -118,7 +118,8 @@
|
||||
(aget sheep-stand-sheet 0 i)))
|
||||
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
|
||||
|
||||
@@ -153,13 +153,15 @@
|
||||
(defn animate [entity screen]
|
||||
(merge entity (animation->texture (update-in screen [:total-time] #(- % (:anim-start entity)))
|
||||
(:anim entity))))
|
||||
|
||||
(defn play-sound [snd]
|
||||
(sound! snd :loop 0.3))
|
||||
|
||||
(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.30)
|
||||
(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)
|
||||
@@ -167,6 +169,10 @@
|
||||
: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 []}
|
||||
|
||||
Reference in New Issue
Block a user