summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2025-08-11 12:21:24 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2025-08-11 12:21:24 +0200
commitfa1aa7793bbe2a3647435798c56f43945278bcd0 (patch)
treeb8f31d4731ebac875b72104b27aeb1b9c36fa8b0 /tests
parent4b38f7f3a34dd696320f61d1fe67e6e1ff7d6795 (diff)
downloadbidi-fa1aa7793bbe2a3647435798c56f43945278bcd0.tar.gz
Added load, play and stop sound functions
Diffstat (limited to 'tests')
-rw-r--r--tests/sounds/effect1.wavbin0 -> 26182 bytes
-rw-r--r--tests/sounds/song1.oggbin0 -> 103277 bytes
-rw-r--r--tests/test.lua23
3 files changed, 21 insertions, 2 deletions
diff --git a/tests/sounds/effect1.wav b/tests/sounds/effect1.wav
new file mode 100644
index 0000000..209c609
--- /dev/null
+++ b/tests/sounds/effect1.wav
Binary files differ
diff --git a/tests/sounds/song1.ogg b/tests/sounds/song1.ogg
new file mode 100644
index 0000000..4a47527
--- /dev/null
+++ b/tests/sounds/song1.ogg
Binary files differ
diff --git a/tests/test.lua b/tests/test.lua
index 372b221..67df27a 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -10,6 +10,9 @@ test_camera_position = { x = 0, y = 0 }
test_camera_speed = 200
test_images_asset1 = load_image("tests/icons/icon_1.png")
test_images_asset2 = load_image("tests/icons/icon_2.png")
+test_sounds_sound1 = load_sound("tests/sounds/effect1.wav")
+test_sounds_sound2 = load_sound("tests/sounds/song1.ogg")
+test_sounds_volume = 100
function test_api()
draw_rect(100, 100, 300, 200, color.YELLOW)
@@ -140,13 +143,28 @@ function test_camera()
end
function test_images()
- draw_text(string.format("uid: %s", test_images_asset1), 50, 50, 20, color.VIOLET)
- draw_text(string.format("uid: %s", test_images_asset2), 50, 80, 20, color.VIOLET)
+ draw_text(string.format("uid: %s", test_images_asset1), 30, 30, 20, color.VIOLET)
+ draw_text(string.format("uid: %s", test_images_asset2), 30, 55, 20, color.VIOLET)
draw_image(test_images_asset1, 150, 150)
draw_image(test_images_asset2, 200, 200)
end
+function test_sounds()
+ draw_text("Press button A to play a short sound effect.", 30, 30, 20, color.BLUE)
+ draw_text("Press button B to play a longer sound effect.", 30, 55, 20, color.BLUE)
+
+ if button_pressed(button.A) then
+ draw_text("Button A pressed", 30, 85, 20, color.YELLOW)
+ play_sound(test_sounds_sound1)
+ end
+
+ if button_pressed(button.B) then
+ draw_text("Button B pressed", 30, 85, 20, color.YELLOW)
+ play_sound(test_sounds_sound2)
+ end
+end
+
while window_running() do
start_drawing()
clear_window(color.BLACK)
@@ -156,6 +174,7 @@ while window_running() do
-- test_buttons()
-- test_camera()
-- test_images()
+ -- test_sounds()
draw_info()
stop_drawing()