sound volume!
This commit is contained in:
BIN
desktop/resources/ui/slider-bar.png
Normal file
BIN
desktop/resources/ui/slider-bar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
desktop/resources/ui/slider.9.png
Normal file
BIN
desktop/resources/ui/slider.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
21
desktop/resources/ui/ui.atlas
Normal file
21
desktop/resources/ui/ui.atlas
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
ui.png
|
||||
size: 32,128
|
||||
format: RGBA8888
|
||||
filter: Nearest,Nearest
|
||||
repeat: none
|
||||
slider
|
||||
rotate: false
|
||||
xy: 2, 2
|
||||
size: 20, 20
|
||||
split: 8, 8, 8, 8
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
slider-bar
|
||||
rotate: false
|
||||
xy: 2, 24
|
||||
size: 20, 40
|
||||
orig: 20, 40
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
5
desktop/resources/ui/ui.json
Normal file
5
desktop/resources/ui/ui.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: {
|
||||
default-horizontal: { background: slider, knob: slider-bar }
|
||||
}}
|
||||
BIN
desktop/resources/ui/ui.png
Normal file
BIN
desktop/resources/ui/ui.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 313 B |
198
desktop/resources/uiskin.atlas
Normal file
198
desktop/resources/uiskin.atlas
Normal file
@@ -0,0 +1,198 @@
|
||||
|
||||
uiskin.png
|
||||
format: RGBA8888
|
||||
filter: Nearest,Nearest
|
||||
repeat: none
|
||||
default
|
||||
rotate: false
|
||||
xy: 1, 50
|
||||
size: 254, 77
|
||||
orig: 254, 77
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-window
|
||||
rotate: false
|
||||
xy: 1, 20
|
||||
size: 27, 29
|
||||
split: 4, 3, 20, 3
|
||||
orig: 27, 29
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-select
|
||||
rotate: false
|
||||
xy: 29, 29
|
||||
size: 27, 20
|
||||
split: 4, 14, 4, 4
|
||||
orig: 27, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round-large
|
||||
rotate: false
|
||||
xy: 57, 29
|
||||
size: 20, 20
|
||||
split: 5, 5, 5, 4
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-scroll
|
||||
rotate: false
|
||||
xy: 78, 29
|
||||
size: 20, 20
|
||||
split: 2, 2, 2, 2
|
||||
orig: 20, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-slider-knob
|
||||
rotate: false
|
||||
xy: 1, 1
|
||||
size: 9, 18
|
||||
orig: 9, 18
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round-down
|
||||
rotate: false
|
||||
xy: 99, 29
|
||||
size: 12, 20
|
||||
split: 5, 5, 5, 4
|
||||
orig: 12, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-round
|
||||
rotate: false
|
||||
xy: 112, 29
|
||||
size: 12, 20
|
||||
split: 5, 5, 5, 4
|
||||
pad: 4, 4, 1, 1
|
||||
orig: 12, 20
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
check-off
|
||||
rotate: false
|
||||
xy: 11, 5
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
textfield
|
||||
rotate: false
|
||||
xy: 11, 5
|
||||
size: 14, 14
|
||||
split: 3, 3, 3, 3
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
check-on
|
||||
rotate: false
|
||||
xy: 125, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-minus
|
||||
rotate: false
|
||||
xy: 140, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-plus
|
||||
rotate: false
|
||||
xy: 155, 35
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-slider
|
||||
rotate: false
|
||||
xy: 29, 20
|
||||
size: 8, 8
|
||||
split: 2, 2, 2, 2
|
||||
orig: 8, 8
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-pane
|
||||
rotate: false
|
||||
xy: 11, 1
|
||||
size: 5, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect-pad
|
||||
rotate: false
|
||||
xy: 11, 1
|
||||
size: 5, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-splitpane
|
||||
rotate: false
|
||||
xy: 17, 1
|
||||
size: 5, 3
|
||||
split: 0, 5, 0, 0
|
||||
orig: 5, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
cursor
|
||||
rotate: false
|
||||
xy: 23, 1
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-splitpane-vertical
|
||||
rotate: false
|
||||
xy: 125, 29
|
||||
size: 3, 5
|
||||
split: 0, 0, 0, 5
|
||||
orig: 3, 5
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect-down
|
||||
rotate: false
|
||||
xy: 170, 46
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-rect
|
||||
rotate: false
|
||||
xy: 38, 25
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-select-selection
|
||||
rotate: false
|
||||
xy: 26, 16
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
default-pane-noborder
|
||||
rotate: false
|
||||
xy: 129, 33
|
||||
size: 1, 1
|
||||
split: 0, 0, 0, 0
|
||||
orig: 1, 1
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
selection
|
||||
rotate: false
|
||||
xy: 170, 44
|
||||
size: 1, 1
|
||||
orig: 1, 1
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
white
|
||||
rotate: false
|
||||
xy: 174, 48
|
||||
size: 1, 1
|
||||
orig: 1, 1
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
59
desktop/resources/uiskin.json
Normal file
59
desktop/resources/uiskin.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: default.fnt } },
|
||||
com.badlogic.gdx.graphics.Color: {
|
||||
green: { a: 1, b: 0, g: 1, r: 0 },
|
||||
white: { a: 1, b: 1, g: 1, r: 1 },
|
||||
red: { a: 1, b: 0, g: 0, r: 1 },
|
||||
black: { a: 1, b: 0, g: 0, r: 0 }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: {
|
||||
dialogDim: { name: white, color: { r: 0, g: 0, b: 0, a: 0.45 } }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
|
||||
default: { down: default-round-down, up: default-round },
|
||||
toggle: { down: default-round-down, checked: default-round-down, up: default-round }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
|
||||
default: { down: default-round-down, up: default-round, font: default-font, fontColor: white },
|
||||
toggle: { down: default-round-down, up: default-round, checked: default-round-down, font: default-font, fontColor: white, downFontColor: red }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: {
|
||||
default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle: {
|
||||
default: {
|
||||
font: default-font, fontColor: white, background: default-select,
|
||||
scrollStyle: default,
|
||||
listStyle: { font: default-font, selection: default-select-selection }
|
||||
}
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle: {
|
||||
default-vertical: { handle: default-splitpane-vertical },
|
||||
default-horizontal: { handle: default-splitpane }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: {
|
||||
default: { titleFont: default-font, background: default-window, titleFontColor: white },
|
||||
dialog: { titleFont: default-font, background: default-window, titleFontColor: white, stageBackground: dialogDim }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: {
|
||||
default-horizontal: { background: default-slider, knob: default-slider-knob }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: {
|
||||
default: { font: default-font, fontColor: white }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: {
|
||||
default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle: {
|
||||
default: { checkboxOn: check-on, checkboxOff: check-off, font: default-font, fontColor: white }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle: {
|
||||
default: { fontColorUnselected: white, selection: default-rect-pad, fontColorSelected: white, font: default-font }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle: {
|
||||
default: { background: default-pane, knob: default-round-large }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle: {
|
||||
default: { minus: tree-minus, plus: tree-plus, selection: default-select-selection }
|
||||
}
|
||||
}
|
||||
BIN
desktop/resources/uiskin.png
Normal file
BIN
desktop/resources/uiskin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -482,7 +482,7 @@
|
||||
(defn give [entities item]
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(sound! (sound "pickup.mp3") :play)
|
||||
(sound! (sound "pickup.mp3") :play (utils/current-sound-volume))
|
||||
|
||||
(-> entities
|
||||
(update-in [:state :inventory] #(conj % item))
|
||||
@@ -552,7 +552,7 @@
|
||||
(let [entities (-> entities
|
||||
(assoc-in [:music-override :value] new-music)
|
||||
(assoc-in [:volume :value] 1.0))]
|
||||
(music! (utils/get-current-music entities) :set-volume 1.0)
|
||||
(music! (utils/get-current-music entities) :set-volume (utils/current-music-volume))
|
||||
(music! (utils/get-current-music entities) :play)
|
||||
entities))
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@
|
||||
(if (get-in @entities [:room :entities :ladder])
|
||||
(do (actions/talk entities :ego "I think he's going for it!")
|
||||
(actions/play-animation entities :ego :cat-toy-first-half :stop? false)
|
||||
(sound! (sound "cat-tree/cat.ogg") :play)
|
||||
(sound! (sound "cat-tree/cat.ogg") :play (utils/current-sound-volume))
|
||||
(actions/walk-straight-to entities :cat [138 40] :update-baseline? false :speed 3)
|
||||
(actions/play-animation entities :ego :cat-toy-last-half)
|
||||
(actions/play-animation entities :grandma :squat-1 :stop? false)
|
||||
@@ -283,7 +283,7 @@
|
||||
:grandma "Come here young man.")
|
||||
(actions/walk-straight-to entities :ego [133 35])
|
||||
(actions/talk entities :grandma "For your impressive display of courage and bravery, I give you this. ")
|
||||
(sound! (sound "cat-tree/kiss.ogg") :play)
|
||||
(sound! (sound "cat-tree/kiss.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :grandma :kiss)
|
||||
(actions/play-animation entities :ego :get-sick :stop? false)
|
||||
(actions/walk-straight-to entities :ego [165 45])
|
||||
|
||||
@@ -211,7 +211,7 @@
|
||||
(actions/talk entities :ego "I'll just try one of these mints.")
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(actions/update-state entities (fn [s] (assoc s :mints-eaten (inc (s :mints-eaten)))))
|
||||
(sound! (sound (str "inside-antique/fire-" (get-in @entities [:state :mints-eaten]) ".ogg")) :play)
|
||||
(sound! (sound (str "inside-antique/fire-" (get-in @entities [:state :mints-eaten]) ".ogg")) :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :ego [:fire (get-in @entities [:state :mints-eaten])])
|
||||
(actions/talk entities :ego "WOWZA! Those are hot.")
|
||||
(when (= 3 (get-in @entities [:state :mints-eaten]))
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
(if (actions/has-item? @entities :flask-1-strength)
|
||||
(do
|
||||
(actions/do-dialogue entities :ego "One sec.")
|
||||
(sound! (sound "ego/potion.ogg") :play)
|
||||
(sound! (sound "ego/potion.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :ego :grow :stop? false)
|
||||
(play-battle entities :win)
|
||||
(actions/do-dialogue entities
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
(begin [this screen entities]
|
||||
(particle-effect! (get-in entities [:room :entities :appear]) :reset)
|
||||
(particle-effect! (get-in entities [:room :entities :appear]) :start)
|
||||
(sound! (sound "inside-house/disappear.ogg") :play)
|
||||
(sound! (sound "inside-house/disappear.ogg") :play (utils/current-sound-volume))
|
||||
(-> entities
|
||||
(assoc-in [:tweens :bloodclot-head-appear]
|
||||
(tween/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 0.0 1.0 1.0 :ease tween/ease-in-quadratic))
|
||||
@@ -101,7 +101,7 @@
|
||||
:game-player "I don't have the might or courage required to pull the sword and fulfill the prophecy. "
|
||||
:game-player "The knights of Remington have muscles the size of tree trunks."
|
||||
:game-player "But me...")
|
||||
(sound! (sound "inside-castle/flex.ogg") :play)
|
||||
(sound! (sound "inside-castle/flex.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :game-player :flex)
|
||||
(actions/do-dialogue entities :game-player "I'd never be able to prove my strength."))
|
||||
:choices actions/previous-choices}
|
||||
@@ -250,7 +250,7 @@
|
||||
:cursor :up
|
||||
:script (actions/get-script entities
|
||||
(actions/walk-to entities :ego [182 90] :face :left)
|
||||
(sound! (sound "door.ogg") :play)
|
||||
(sound! (sound "door.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(if (= :night (get-in @entities [:state :time]))
|
||||
(actions/talk entities :ego "It's locked.")
|
||||
@@ -443,12 +443,7 @@
|
||||
entities)
|
||||
(if (= :night (get-in entities [:state :time]))
|
||||
(make-night entities)
|
||||
entities)
|
||||
#_(let [chorus
|
||||
instance (sound! chorus :loop 0.0)]
|
||||
(-> entities
|
||||
(assoc-in [:room :chorus :sound] chorus)
|
||||
(assoc-in [:room :chorus :instance] instance)))))
|
||||
entities)))
|
||||
:update-fn (fn [screen entities]
|
||||
#_(when (and (actions/has-obtained? entities :sword)
|
||||
(get-in entities [:room :entities :magic])
|
||||
@@ -464,8 +459,8 @@
|
||||
(if (:instance chorus)
|
||||
(do (sound! (:sound chorus) :set-volume
|
||||
(:instance chorus)
|
||||
chorus-volume)
|
||||
(utils/current-sound-volume chorus-volume))
|
||||
entities)
|
||||
(assoc-in entities [:room :chorus :instance] (sound! (:sound chorus) :loop
|
||||
chorus-volume)))))))
|
||||
(utils/current-sound-volume chorus-volume))))))))
|
||||
:start-pos [245 90])))
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
:wizard "Ok, I'll deliver them myself. Don't touch anything while I'm gone.")
|
||||
(actions/update-state entities (fn [s] (assoc s :mints-eaten 0
|
||||
:wizard-left? true)))
|
||||
(sound! (sound "inside-house/disappear.ogg") :play)
|
||||
(sound! (sound "inside-house/disappear.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :wizard :disappear :stop? false)
|
||||
(actions/remove-entity entities :wizard))}
|
||||
"Nevermind."
|
||||
|
||||
@@ -279,7 +279,7 @@
|
||||
entities
|
||||
(actions/walk-to entities :ego [267 90])
|
||||
(actions/talk entities :ego (str "Anyone home?"))
|
||||
(sound! (sound "door.ogg") :play)
|
||||
(sound! (sound "door.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :ego :reach)
|
||||
(if (= :night (get-in @entities [:state :time]))
|
||||
(actions/talk entities :ego "It's locked.")
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
(not (get-in entities [:state :blergh-dead?]))
|
||||
(actions/has-item? entities :magic-slingshot))
|
||||
((actions/get-script entities
|
||||
(sound! (sound "space/shock.ogg") :play)
|
||||
(sound! (sound "space/shock.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :bloodclot-head :shoot :stop? false)
|
||||
(actions/begin-animation entities :bloodclot-head :keep-shoot)
|
||||
(actions/do-dialogue entities :bloodclot-head "Dang! Come a little closer!"))
|
||||
@@ -56,7 +56,7 @@
|
||||
(begin [this screen entities]
|
||||
(particle-effect! (get-in entities [:room :entities :appear]) :reset)
|
||||
(particle-effect! (get-in entities [:room :entities :appear]) :start)
|
||||
(sound! (sound "inside-house/disappear.ogg") :play)
|
||||
(sound! (sound "inside-house/disappear.ogg") :play (utils/current-sound-volume))
|
||||
(-> entities
|
||||
(assoc-in [:tweens :bloodclot-head-appear]
|
||||
(tween/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic))
|
||||
@@ -85,7 +85,7 @@
|
||||
(actions/run-action entities
|
||||
(begin [this screen entities]
|
||||
|
||||
(sound! (sound "space/jump.ogg") :play)
|
||||
(sound! (sound "space/jump.ogg") :play (utils/current-sound-volume))
|
||||
(-> entities
|
||||
(assoc-in [:room :entities :cloud] (assoc (texture "space/cloud.png")
|
||||
:x (- (get-in entities [:room :entities :ego :x]) 10)
|
||||
@@ -132,7 +132,7 @@
|
||||
(actions/run-action entities
|
||||
(begin [this screen entities]
|
||||
|
||||
(sound! (sound "space/swingsword.ogg") :play)
|
||||
(sound! (sound "space/swingsword.ogg") :play (utils/current-sound-volume))
|
||||
(-> entities
|
||||
(update-in [:room :entities :ego]
|
||||
#(actions/start-animation screen % :swing))
|
||||
@@ -232,7 +232,7 @@
|
||||
(actions/do-dialogue entities :bloodclot-head "Ha ha ha! Is that the best you can do?"
|
||||
:bloodclot-head "Take this!")
|
||||
|
||||
(sound! (sound "space/shock.ogg") :play)
|
||||
(sound! (sound "space/shock.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :bloodclot-head :shoot :stop? false)
|
||||
(actions/begin-animation entities :bloodclot-head :keep-shoot)
|
||||
(actions/play-animation entities :ego :shock :stop? false)
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
(when (:shown? entities)
|
||||
(let [[x y] (utils/unproject screen)]
|
||||
(if-let [button (get-button [x y])]
|
||||
(do (sound! (:sound button) :play)
|
||||
(do (sound! (:sound button) :play (utils/current-sound-volume))
|
||||
(let [new-state (update-in entities [:button-choices] #(conj % (:id button)))]
|
||||
|
||||
(cond (= [4 2 1 5 3] (:button-choices new-state))
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
(defn drink-blergh [entities]
|
||||
(actions/walk-straight-to entities :ego [205 45])
|
||||
(sound! (sound "ego/potion.ogg") :play)
|
||||
(sound! (sound "ego/potion.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :ego :grow :stop? false)
|
||||
(actions/do-dialogue entities
|
||||
:blergh "What this? A potion of strength?"
|
||||
@@ -290,7 +290,7 @@
|
||||
:else
|
||||
(do
|
||||
(actions/talk entities :ego "I'll just take a sip!")
|
||||
(sound! (sound "ego/potion.ogg") :play)
|
||||
(sound! (sound "ego/potion.ogg") :play (utils/current-sound-volume))
|
||||
(actions/play-animation entities :ego :grow :stop? false))))
|
||||
:recipe (actions/get-script entities (actions/do-dialogue entities
|
||||
:ego "The recipe says:"
|
||||
@@ -402,7 +402,7 @@
|
||||
|
||||
(defn fade-in-first-time-if-necessary [screen entities]
|
||||
(if (not (get-in entities [:started? :value]))
|
||||
(do (music! (utils/get-current-music entities) :set-volume (get-in entities [:volume :value]))
|
||||
(do (music! (utils/get-current-music entities) :set-volume (utils/current-music-volume (get-in entities [:volume :value])))
|
||||
(utils/play-sound (get-in entities [:musics (actions/get-music (get-in entities [:room :music]) (get-in entities [:state :time]))]))
|
||||
(assoc entities
|
||||
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0 :ease tween/ease-in-cubic)
|
||||
@@ -429,7 +429,7 @@
|
||||
vol (* vol vol-scale)
|
||||
vol (max vol 0.005)]
|
||||
(sound! (or (snd e)
|
||||
(snd (:sounds entities))) :play vol 1.0 pan))))))
|
||||
(snd (:sounds entities))) :play (utils/current-sound-volume vol) 1.0 pan))))))
|
||||
|
||||
(defn update-from-room [screen entities]
|
||||
(if-let [update-fn (get-in entities [:room :update-fn])]
|
||||
@@ -629,7 +629,7 @@
|
||||
(play-key-sounds entities))
|
||||
(doseq [m (vals (get-in entities [:musics]))]
|
||||
(when m
|
||||
(music! m :set-volume (get-in entities [:volume :value]))))
|
||||
(music! m :set-volume (utils/current-music-volume (get-in entities [:volume :value])))))
|
||||
(doseq [e (sort-by :baseline all-entities)]
|
||||
(if (:parallax e)
|
||||
(render-parallax screen e)
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
(fn [screen entities]
|
||||
(let [cam (orthographic)
|
||||
viewport (FitViewport. 1280 960 cam)]
|
||||
(utils/load-settings!)
|
||||
(update! screen :renderer (stage) :camera cam :viewport viewport)
|
||||
(.apply viewport)
|
||||
(let [font (utils/get-font "ego/font.fnt")
|
||||
@@ -43,7 +44,8 @@
|
||||
start-playing (center start-playing)
|
||||
quit (assoc (label "Quit thy adventure" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 50)
|
||||
quit (center quit)
|
||||
music (utils/make-music "intro.ogg")]
|
||||
music (utils/make-music "intro.ogg")
|
||||
ui-skin (skin "ui/ui.json")]
|
||||
(label! start-playing :set-alignment Align/center)
|
||||
|
||||
{:overlay (assoc (texture "title-overlay.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
|
||||
@@ -51,6 +53,16 @@
|
||||
:scale-x 80
|
||||
:scale-y 80
|
||||
:opacity 1.0)
|
||||
:music-volume-slider (assoc (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings))
|
||||
:x ( - (/ (game :width) 2)
|
||||
150)
|
||||
:width 300
|
||||
:y 200)
|
||||
:sound-volume-slider (assoc (slider {:min 0 :max 100 :step 1 } ui-skin :set-value (:sound-volume @utils/settings))
|
||||
:width 300
|
||||
:x ( - (/ (game :width) 2)
|
||||
150)
|
||||
:y 150)
|
||||
:viewport viewport
|
||||
:font font
|
||||
:music music
|
||||
@@ -60,8 +72,7 @@
|
||||
:quit quit
|
||||
: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)}
|
||||
})))
|
||||
:ease tween/ease-in-quadratic)}})))
|
||||
|
||||
:on-render
|
||||
(fn [screen [entities]]
|
||||
@@ -71,8 +82,8 @@
|
||||
|
||||
(clear!)
|
||||
(let [entities (utils/apply-tweens screen entities (:tweens entities))]
|
||||
(music! (:music entities) :set-volume 0.0 #_(:volume entities))
|
||||
(render! screen [(:overlay entities) (:start-playing entities) (:quit entities) (:fade entities)])
|
||||
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
|
||||
(render! screen [(:overlay entities) (:start-playing entities) (:quit entities) (:music-volume-slider entities) (:sound-volume-slider entities) (:fade entities) ])
|
||||
entities))
|
||||
|
||||
:show-screen (fn [entities]
|
||||
@@ -83,6 +94,14 @@
|
||||
(style-label (:start-playing entities) (get-in entities [:font]) [x y])
|
||||
(style-label (:quit entities) (get-in entities [:font]) [x y])
|
||||
entities))
|
||||
:on-ui-changed
|
||||
(fn [screen [entities]]
|
||||
(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]]
|
||||
(let [[x y] (utils/unproject screen)]
|
||||
@@ -97,7 +116,7 @@
|
||||
entities)
|
||||
:ease tween/ease-in-cubic))
|
||||
(assoc-in [:tweens :fade-out-music]
|
||||
(tween/tween :fade-out-music screen [:volume] 1.0 0.0 1.8)))
|
||||
(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]
|
||||
@@ -111,6 +130,5 @@
|
||||
nil)))
|
||||
|
||||
:on-resize (fn [screen [entities]]
|
||||
(println (game :width) (game :height) (:width screen) (:height screen))
|
||||
(.update (:viewport entities) (game :width) (game :height) true)
|
||||
nil))
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.math :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.edn :as edn])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
@@ -18,6 +19,19 @@
|
||||
|
||||
(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :ladder :stick :cat-toy :balloon :frog-legs :teddy :portrait :recipe :glass-eye :motivational-tapes :used-earplugs :grass :slobber :flask-with-strength :medal :kiss :sword :hourglass :mandrake :ball-n-chain :key :rope :crowbar :note-1 :ash :sack-lunch :flies :spear :monocle :feather :spell-component :money :watch :broken-clock :slingshot :camera :walkie-talkies :alarm-clock :walkie-talkie :flask-water :flask-water-stuff :flask-water-stuff-2 :note-2 :magic-slingshot])
|
||||
|
||||
(def settings (atom {:music-volume 50.0
|
||||
:sound-volume 75.0}))
|
||||
|
||||
(defn current-music-volume [& [factor]]
|
||||
(* (Math/pow (/ (:music-volume @settings) 100.0) 2)
|
||||
0.25
|
||||
(or factor 1.0)))
|
||||
|
||||
(defn current-sound-volume [& [factor]]
|
||||
(* (Math/pow (/ (:sound-volume @settings) 100.0) 2)
|
||||
0.5
|
||||
(or factor 1.0)))
|
||||
|
||||
(defn cursor [filename which]
|
||||
(let [scale 2
|
||||
base-cursor (pixmap filename)
|
||||
@@ -36,6 +50,13 @@
|
||||
(defn load []
|
||||
(assoc (edn/read-string (slurp "save.edn")) :active? true))
|
||||
|
||||
(defn load-settings! []
|
||||
(when (.exists (io/file "settings.edn"))
|
||||
(reset! settings (edn/read-string (slurp "settings.edn")))))
|
||||
|
||||
(defn save-settings! []
|
||||
(spit "settings.edn" @settings))
|
||||
|
||||
(defn get-font [filename]
|
||||
(let [font (bitmap-font filename)
|
||||
tr (bitmap-font! font :get-region)
|
||||
|
||||
Reference in New Issue
Block a user