]> git.seodisparate.com - LudumDare45_StartWithNothing/commitdiff
Add some sfx and loading
authorStephen Seo <seo.disparate@gmail.com>
Sat, 5 Oct 2019 01:16:37 +0000 (10:16 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 5 Oct 2019 01:16:37 +0000 (10:16 +0900)
src/main.rs
static/boom.mp3 [new file with mode: 0644]
static/get.mp3 [new file with mode: 0644]
static/power_up.mp3 [new file with mode: 0644]
static/speak_f.mp3 [new file with mode: 0644]
static/speak_m.mp3 [new file with mode: 0644]
static/tap.mp3 [new file with mode: 0644]

index eded4a1fa4df1c1d468a558122b6374d99f31be4..3e108dee2299638809647522fda6b2ebc2ef97a9 100644 (file)
@@ -2,16 +2,33 @@ use quicksilver::{
     geom::{Circle, Rectangle, Vector},
     graphics::{Background::Col, Color},
     input::{ButtonState, Key},
-    lifecycle::{run, Event, Settings, State, Window},
+    lifecycle::{Asset, run, Event, Settings, State, Window},
     Result,
+    sound::Sound,
 };
 use rand::prelude::*;
 
-struct GameState {}
+struct GameState {
+    s_boom: Asset<Sound>,
+    s_get: Asset<Sound>,
+    s_power_up: Asset<Sound>,
+    s_tap: Asset<Sound>,
+    s_speak_m: Asset<Sound>,
+    s_speak_f: Asset<Sound>,
+    timer: f64,
+}
 
 impl State for GameState {
     fn new() -> Result<Self> {
-        Ok(Self {})
+        Ok(Self {
+            s_boom: Asset::new(Sound::load("boom.mp3")),
+            s_get: Asset::new(Sound::load("get.mp3")),
+            s_power_up: Asset::new(Sound::load("power_up.mp3")),
+            s_tap: Asset::new(Sound::load("tap.mp3")),
+            s_speak_m: Asset::new(Sound::load("speak_m.mp3")),
+            s_speak_f: Asset::new(Sound::load("speak_f.mp3")),
+            timer: 0.0,
+        })
     }
 
     fn event(&mut self, event: &Event, window: &mut Window) -> Result<()> {
@@ -19,6 +36,8 @@ impl State for GameState {
     }
 
     fn update(&mut self, window: &mut Window) -> Result<()> {
+        let dt = window.update_rate();
+        self.timer += dt;
         Ok(())
     }
 
diff --git a/static/boom.mp3 b/static/boom.mp3
new file mode 100644 (file)
index 0000000..2e1bee0
Binary files /dev/null and b/static/boom.mp3 differ
diff --git a/static/get.mp3 b/static/get.mp3
new file mode 100644 (file)
index 0000000..ab8cb54
Binary files /dev/null and b/static/get.mp3 differ
diff --git a/static/power_up.mp3 b/static/power_up.mp3
new file mode 100644 (file)
index 0000000..46a2e25
Binary files /dev/null and b/static/power_up.mp3 differ
diff --git a/static/speak_f.mp3 b/static/speak_f.mp3
new file mode 100644 (file)
index 0000000..a7c83de
Binary files /dev/null and b/static/speak_f.mp3 differ
diff --git a/static/speak_m.mp3 b/static/speak_m.mp3
new file mode 100644 (file)
index 0000000..764debf
Binary files /dev/null and b/static/speak_m.mp3 differ
diff --git a/static/tap.mp3 b/static/tap.mp3
new file mode 100644 (file)
index 0000000..6172e31
Binary files /dev/null and b/static/tap.mp3 differ