added new sounds

This commit is contained in:
Bryce Covert
2015-07-25 17:56:00 -07:00
parent b5432bd333
commit f4425c1bd4
10 changed files with 227 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +1 @@
{:sound-volume 42.0, :music-volume 59.0}
{:sound-volume 97.0, :music-volume 77.0}

View File

@@ -0,0 +1,220 @@
(ns advent.screens.title
(:require [play-clj.core :refer :all]
[play-clj.math :refer :all]
[play-clj.ui :refer :all]
[play-clj.utils :refer :all]
[play-clj.g2d :refer :all]
[advent.utils :as utils]
[advent.tween :as tween]
[advent.screens.scene :as scene]
[advent.screens.dialogue :as dialogue]
[advent.screens.title :as title]
[advent.screens.inventory :as inventory]
[advent.screens.safe :as safe]
[advent.screens.fade :as fade]
)
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.utils.viewport FitViewport]
[com.badlogic.gdx.scenes.scene2d.ui Slider$SliderStyle]
[com.badlogic.gdx.scenes.scene2d.utils Align]
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
InputMultiplexer InputProcessor Net Preferences Screen]))
(defn get-color [e mouse-pos]
(if (utils/intersects? e mouse-pos)
(color :yellow)
(color 0.6 1.0 1.0 1.0)))
(defn style-label [e font mouse-pos]
(label! e :set-style (style :label font (get-color e mouse-pos)))
e)
(defn style-slider [s mouse-pos]
(if (utils/intersects? s mouse-pos)
(slider! s :set-style (:hover s))
(slider! s :set-style (:default s)))
s)
(defn center [e]
(assoc e :x (- (/ 1280 2) (/ (or (:width e) (.getWidth (:object e))) 2))))
(defn get-dir [old-x new-x]
(if (< old-x new-x)
:right
:left))
(defn fly-ego [screen entities]
(let [speed 0.07
pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed)))
v (vector-2 0 0)
a (catmull-rom-spline! (:path (:flying-ego entities)) :value-at v pos-f)
direction (get-dir (get-in entities [:flying-ego :x]) (vector-2! v :x))
x (vector-2! v :x)
y (vector-2! v :y)]
(update-in entities [:flying-ego]
\(update-in\ entities\ \[:flying-ego\]
-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ merge\ {:x\ \(vector-2\!\ v\ :x\)
-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :y\ \(vector-2\!\ v\ :y\)}
-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(get-in\ entities\ \[:flying-ego\ direction\]\)
-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\)\)
assoc :x xb :y y
)))
(defn flip [t]
(let [flipped (texture t)]
(texture! flipped :flip true false)
flipped))
(defscreen title-screen
:on-show
(fn [screen entities]
(utils/setup-viewport screen 1280 960)
(utils/load-settings!)
(let [font (utils/get-font "ego/font.fnt")
start-playing (assoc (label "Begin quest" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 280 :height 32 :origin-x 0 :origin-y 0)
start-playing (center start-playing)
fullscreen (assoc (label "Windowed" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y (- 280 (* 32 5)) :height 32 :origin-x 0 :origin-y 0)
fullscreen (center fullscreen)
quit (assoc (label "End quest" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y (- 280 (* 32 6)) :height 32 :origin-x 0 :origin-y 0)
quit (center quit)
music (utils/make-music "intro.ogg")
ui-skin (skin "ui/ui.json")
]
(label! start-playing :set-alignment Align/center)
(label! quit :set-alignment Align/center)
(label! fullscreen :set-alignment Align/center)
{:overlay (assoc (texture "title.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
:fade (assoc (texture "black.png")
:scale-x 80
:scale-y 80
:opacity 1.0
:origin-x 0
:origin-y 0)
:flying-ego (assoc (texture "ego/flying.png")
:left (flip (texture "ego/flying.png"))
:right (texture "ego/flying.png")
:scale-x 5
:scale-y 5
:origin-x 2
:origin-y 0
:path (catmull-rom-spline (map #(apply vector-2* %) [[-800 450] [1280 450] [2000 100] [0 100] [-800 300] [1280 300] [2000 450]]) true)
:x 450
:y 650)
:clouds (assoc (particle-effect "titleclouds" :reset :start) :x 640 :y 480 )
:toolbox (center (assoc (nine-patch {:region (:object (texture "talk-bg-2.png")) :left 9 :top 9 :right 9 :bottom 9})
:y 58 :width 500 :height 282))
:music-label (-> (label "Music" (style :label font (color 1.0 1.0 1.0 1.0)))
(assoc :x 0 :y (- 280 (* 32 1)) :height 32 :origin-x 0 :origin-y 0)
center)
:music-volume-slider (-> (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings))
(assoc :x (- (/ 1280 2) 150)
:width 300
:y (- 280 (* 32 2))
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle)))
:sound-label (->
(label "FX" (style :label font (color 1.0 1.0 1.0 1.0)))
(assoc :x 0 :y (- 280 (* 32 3)) :height 32 :origin-x 0 :origin-y 0)
center)
:sound-volume-slider (assoc (slider {:min 0 :max 100 :step 1 } ui-skin :set-value (:sound-volume @utils/settings))
:width 300
:x ( - (/ 1280 2)
150)
:y (- 280 (* 32 4))
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle))
:font font
:music music
:volume 1.0
:start-playing start-playing
:quit quit
:fullscreen fullscreen
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0
:finish #(do (utils/play-sound (:music %)) %)
:ease tween/ease-in-quadratic)}}))
:on-render
(fn [screen [entities]]
(clear!)
(let [entities (utils/apply-tweens screen entities (:tweens entities))
entities (fly-ego screen entities)]
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
(render! screen [(:overlay entities) (:clouds entities) (:flying-ego entities) (:toolbox entities) (:start-playing entities) (:quit entities) (:fullscreen entities) (:music-label entities) (:music-volume-slider entities) (:sound-label entities) (:sound-volume-slider entities) (:fade entities) ])
entities))
:show-screen (fn [entities]
entities)
:on-mouse-moved (fn [screen [entities]]
(let [[x y] (utils/unproject screen)]
(style-label (:start-playing entities) (get-in entities [:font]) [x y])
(style-label (:fullscreen entities) (get-in entities [:font]) [x y])
(style-label (:quit entities) (get-in entities [:font]) [x y])
(style-slider (:music-volume-slider entities) [x y])
(style-slider (:sound-volume-slider entities) [x y])
entities))
:on-ui-changed
(fn [screen [entities]]
(println (slider! (:music-volume-slider entities) :get-value))
(if (= 0.0 (slider! (:music-volume-slider entities) :get-value))
(throw (Exception.)))
(swap! utils/settings
assoc
:music-volume (slider! (:music-volume-slider entities) :get-value)
:sound-volume (slider! (:sound-volume-slider entities) :get-value))
(utils/save-settings!)
entities)
:on-touch-up (fn [screen [entities]]
(when-not (get-in entities [:tweens :fade-out])
(let [[x y] (utils/unproject screen)]
(cond
(utils/intersects? (:start-playing entities) [x y])
(-> entities
(assoc-in [:tweens :fade-out]
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
:finish (fn [entities]
(utils/stop-sound (:music entities))
(set-screen! @(resolve 'advent.core/advent) scene/scene scene/hud dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen fade/fade-screen)
entities)
:ease tween/ease-in-cubic))
(assoc-in [:tweens :fade-out-music]
(tween/tween :fade-out-music screen [:volume] 1.0 0.0 1.0)))
(utils/intersects? (:quit entities) [x y])
(-> entities
(assoc-in [:tweens :fade-out]
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
:finish (fn [entities]
(System/exit 0)
entities)
:ease tween/ease-in-cubic)))
(utils/intersects? (:fullscreen entities) [x y])
(if (.isFullscreen Gdx/graphics)
(on-gl (.setDisplayMode Gdx/graphics 1280 960 false)
(label! (:fullscreen entities) set-text "Windowed"))
(on-gl (.setDisplayMode Gdx/graphics
(.width (.getDesktopDisplayMode Gdx/graphics))
(.height (.getDesktopDisplayMode Gdx/graphics))
true)
(label! (:fullscreen entities) set-text "Fullscreen")))
:else
nil))))
:on-resize (fn [{:keys [viewport width height]} [entities]]
(.update viewport width height)
nil))

View File

@@ -151,6 +151,7 @@
(Thread/sleep 500)
(actions/talk entities :fairy-godfather "Taaaaaaaaaaaaaaaaaa-")
(sound! (sound "dream/appear.ogg") :play (utils/current-sound-volume))
(particle-effect! (get-in @entities [:room :entities :magic]) :reset)
(particle-effect! (get-in @entities [:room :entities :magic]) :start)
(Thread/sleep 500)
@@ -169,6 +170,7 @@
:fairy-godfather "Behold!")
(particle-effect! (get-in @entities [:room :entities :magic]) :reset)
(particle-effect! (get-in @entities [:room :entities :magic]) :start)
(sound! (sound "dream/appear.ogg") :play (utils/current-sound-volume))
(fade-in-tools entities)
(Thread/sleep 2500)

View File

@@ -471,6 +471,7 @@ void main()
:step-sound-1 (sound "ego/step-1.ogg")
:step-sound-2 (sound "ego/step-2.ogg")
:sigh-sound (sound "ego/sigh.ogg")
:breakglass-sound (sound "ego/breakglass.ogg")
:blink (sound "blink.ogg")
:scale-x start-scale
:scale-y start-scale
@@ -542,7 +543,9 @@ void main()
(get-in ego [:right :sigh]) {1 [:sigh-sound 0.4]}
(get-in ego [:left :milk]) {8 [:milk-sound 1.0]}
(get-in ego [:right :milk]) {8 [:milk-sound 1.0]}
}
(get-in ego [:left :swing-shovel]) {3 [:breakglass-sound 1.0]}
(get-in ego [:right :swing-shovel]) {3 [:breakglass-sound 1.0]}}
:anim-merges {(get-in ego [:right :shock]) {:origin-x 15}
(get-in ego [:left :swing-shovel]) {:origin-x 26}
(get-in ego [:right :swing-shovel]) {:origin-x 26}