ya2 · news · projects · code · about

authorFlavio Calva <f.calva@gmail.com>
Sat, 8 Jan 2022 14:35:06 +0000 (15:35 +0100)
committerFlavio Calva <f.calva@gmail.com>
Sat, 8 Jan 2022 14:35:06 +0000 (15:35 +0100)
24 files changed:
assets/audio/music/beautiful_day.ogg [new file with mode: 0644]
assets/audio/music/blithe.ogg [new file with mode: 0644]
assets/audio/music/carefree.ogg [new file with mode: 0644]
assets/audio/music/dreamscape.ogg [new file with mode: 0644]
assets/audio/music/happy_sad.ogg [new file with mode: 0644]
assets/audio/music/home_sweet_home.ogg [new file with mode: 0644]
assets/audio/music/joy.ogg [new file with mode: 0644]
assets/audio/music/leaves.ogg [new file with mode: 0644]
assets/audio/music/levitate.ogg [new file with mode: 0644]
assets/audio/music/magic_moment.ogg [new file with mode: 0644]
assets/audio/sfx/click.ogg [new file with mode: 0644]
assets/audio/sfx/grab.ogg [new file with mode: 0644]
assets/audio/sfx/hit.ogg [new file with mode: 0644]
assets/audio/sfx/overlap.ogg [new file with mode: 0644]
assets/audio/sfx/release.ogg [new file with mode: 0644]
assets/audio/sfx/rollover.ogg [new file with mode: 0644]
assets/audio/sfx/success.ogg [new file with mode: 0644]
assets/buttons/exitRight.png [new file with mode: 0644]
pmachines/music.py [new file with mode: 0644]

diff --git a/assets/audio/music/beautiful_day.ogg b/assets/audio/music/beautiful_day.ogg
new file mode 100644 (file)
index 0000000..63a54d2
Binary files /dev/null and b/assets/audio/music/beautiful_day.ogg differ
diff --git a/assets/audio/music/blithe.ogg b/assets/audio/music/blithe.ogg
new file mode 100644 (file)
index 0000000..f42a03c
Binary files /dev/null and b/assets/audio/music/blithe.ogg differ
diff --git a/assets/audio/music/carefree.ogg b/assets/audio/music/carefree.ogg
new file mode 100644 (file)
index 0000000..07c68ae
Binary files /dev/null and b/assets/audio/music/carefree.ogg differ
diff --git a/assets/audio/music/dreamscape.ogg b/assets/audio/music/dreamscape.ogg
new file mode 100644 (file)
index 0000000..ef143ff
Binary files /dev/null and b/assets/audio/music/dreamscape.ogg differ
diff --git a/assets/audio/music/happy_sad.ogg b/assets/audio/music/happy_sad.ogg
new file mode 100644 (file)
index 0000000..4f6a389
Binary files /dev/null and b/assets/audio/music/happy_sad.ogg differ
diff --git a/assets/audio/music/home_sweet_home.ogg b/assets/audio/music/home_sweet_home.ogg
new file mode 100644 (file)
index 0000000..f5b39fe
Binary files /dev/null and b/assets/audio/music/home_sweet_home.ogg differ
diff --git a/assets/audio/music/joy.ogg b/assets/audio/music/joy.ogg
new file mode 100644 (file)
index 0000000..2eef693
Binary files /dev/null and b/assets/audio/music/joy.ogg differ
diff --git a/assets/audio/music/leaves.ogg b/assets/audio/music/leaves.ogg
new file mode 100644 (file)
index 0000000..8500a59
Binary files /dev/null and b/assets/audio/music/leaves.ogg differ
diff --git a/assets/audio/music/levitate.ogg b/assets/audio/music/levitate.ogg
new file mode 100644 (file)
index 0000000..ea2c372
Binary files /dev/null and b/assets/audio/music/levitate.ogg differ
diff --git a/assets/audio/music/magic_moment.ogg b/assets/audio/music/magic_moment.ogg
new file mode 100644 (file)
index 0000000..f291324
Binary files /dev/null and b/assets/audio/music/magic_moment.ogg differ
diff --git a/assets/audio/sfx/click.ogg b/assets/audio/sfx/click.ogg
new file mode 100644 (file)
index 0000000..c5e2515
Binary files /dev/null and b/assets/audio/sfx/click.ogg differ
diff --git a/assets/audio/sfx/grab.ogg b/assets/audio/sfx/grab.ogg
new file mode 100644 (file)
index 0000000..603d700
Binary files /dev/null and b/assets/audio/sfx/grab.ogg differ
diff --git a/assets/audio/sfx/hit.ogg b/assets/audio/sfx/hit.ogg
new file mode 100644 (file)
index 0000000..c8fe970
Binary files /dev/null and b/assets/audio/sfx/hit.ogg differ
diff --git a/assets/audio/sfx/overlap.ogg b/assets/audio/sfx/overlap.ogg
new file mode 100644 (file)
index 0000000..a37caaa
Binary files /dev/null and b/assets/audio/sfx/overlap.ogg differ
diff --git a/assets/audio/sfx/release.ogg b/assets/audio/sfx/release.ogg
new file mode 100644 (file)
index 0000000..543234e
Binary files /dev/null and b/assets/audio/sfx/release.ogg differ
diff --git a/assets/audio/sfx/rollover.ogg b/assets/audio/sfx/rollover.ogg
new file mode 100644 (file)
index 0000000..f9da46d
Binary files /dev/null and b/assets/audio/sfx/rollover.ogg differ
diff --git a/assets/audio/sfx/success.ogg b/assets/audio/sfx/success.ogg
new file mode 100644 (file)
index 0000000..8522835
Binary files /dev/null and b/assets/audio/sfx/success.ogg differ
diff --git a/assets/buttons/exitRight.png b/assets/buttons/exitRight.png
new file mode 100644 (file)
index 0000000..7c2ca28
Binary files /dev/null and b/assets/buttons/exitRight.png differ
index ae50e85c952f38fda6d016d58986f1f03b681aff..650526dcefb11a939404ad1caff1d94904b1b0c1 100644 (file)
@@ -1,4 +1,8 @@
 Assets' attribution
 Font hanken https://fontlibrary.org/en/font/hanken
-Buttons https://opengameart.org/content/game-icons
\ No newline at end of file
+Buttons https://opengameart.org/content/game-icons
+Music by Stefan Grossmann https://soundcloud.com/stefan-grossmann-1
+    https://opengameart.org/content/free-music-pack-one-of-three
+    https://opengameart.org/content/free-music-pack-two-of-three
+Sfx https://opengameart.org/content/sound-effects-pack
index e7add63e21493bd6a9eab131d205710dff9f0cf6..cb8c5efcab81d495618a0e85bd348f149e314eb1 100644 (file)
@@ -41,11 +41,15 @@ class Box:
     def on_click_l(self, pos):
         self._start_drag_pos = pos, self._np.get_pos()
+        loader.load_sfx('assets/audio/sfx/grab.ogg').play()
     def on_click_r(self, pos):
         self._start_rot_info = pos, self._np.get_pos(), self._np.get_r()
+        loader.load_sfx('assets/audio/sfx/grab.ogg').play()
     def on_release(self):
+        if self._start_drag_pos or self._start_rot_info:
+            loader.load_sfx('assets/audio/sfx/release.ogg').play()
         self._start_drag_pos = self._start_rot_info = None
     def on_mouse_on(self):
diff --git a/pmachines/music.py b/pmachines/music.py
new file mode 100644 (file)
index 0000000..71d2cf1
--- /dev/null
@@ -0,0 +1,25 @@
+from glob import glob
+from random import choice
+from logging import info
+from panda3d.core import AudioSound
+class MusicMgr:
+    def __init__(self):
+        self._start_music(glob('assets/audio/music/*.ogg'))
+        base.musicManager.setVolume(.8)
+        base.sfxManagerList[0].setVolume(1)
+        taskMgr.add(self._on_frame, 'on frame music')
+    def _start_music(self, files):
+        self._music = loader.load_music(choice(files))
+        info('playing music ' + self._music.get_name())
+        self._music.play()
+    def _on_frame(self, task):
+        if self._music.status() == AudioSound.READY:
+            files = glob('assets/audio/music/*.ogg')
+            files.remove('assets/audio/music/' + self._music.get_name())
+            self._start_music(files)
+        return task.cont
index 2e9e73d9a90ea947b4d07255d632dfa9641912a1..2cfbd61108bb3f225200f82696feee6b7a9fbe50 100755 (executable)
@@ -9,6 +9,7 @@ from panda3d.core import Filename, load_prc_file_data, AntialiasAttrib
 from panda3d.bullet import BulletWorld, BulletDebugNode
 from direct.showbase.ShowBase import ShowBase
 from pmachines.scene import Scene
+from pmachines.music import MusicMgr
 class Pmachines:
@@ -24,6 +25,7 @@ class Pmachines:
         self.version = args.version
         if args.update:
+        MusicMgr()
index 75886b4c5d3213e8148b739c2ac16e0fc2dcccd1..f67c45b75587804f3ca316eb6455df4e94c548eb 100644 (file)
@@ -71,7 +71,9 @@ class Scene(DirectObject):
             btn = DirectButton(
                 image=imgs, scale=.05, pos=(sign * (.06 + .11 * num), 1, .06),
                 parent=binfo[3], command=binfo[1], state=binfo[2], relief=FLAT,
-                frameColor=fcols[0] if binfo[2] == NORMAL else fcols[1])
+                frameColor=fcols[0] if binfo[2] == NORMAL else fcols[1],
+                rolloverSound=loader.load_sfx('assets/audio/sfx/rollover.ogg'),
+                clickSound=loader.load_sfx('assets/audio/sfx/click.ogg'))
     def _set_directional_light(self, name, hpr, color):
diff --git a/prj.org b/prj.org
index de7dc9fb5f90b2249aa161286e8a347b1390e64f..4f90573796f3239bdf66022c0903bf5f04484ca2 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -1,9 +1,9 @@
 * issues
 * todo
-** music and sfx
-** instructions
-** configuration (physics debug)
 ** rotation with vectors/quaternions (fixes some glitches)
+** configuration (physics debug, music/sfx volume)
+** logging.info|debug in the console
+** instructions
 ** main menu
 ** implement the operations of the buttons
 ** build pipeline