summaryrefslogtreecommitdiff
path: root/tests/test.lua
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/test.lua
parent4b38f7f3a34dd696320f61d1fe67e6e1ff7d6795 (diff)
downloadbidi-fa1aa7793bbe2a3647435798c56f43945278bcd0.tar.gz
Added load, play and stop sound functions
Diffstat (limited to 'tests/test.lua')
-rw-r--r--tests/test.lua23
1 files changed, 21 insertions, 2 deletions
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 }
10test_camera_speed = 200 10test_camera_speed = 200
11test_images_asset1 = load_image("tests/icons/icon_1.png") 11test_images_asset1 = load_image("tests/icons/icon_1.png")
12test_images_asset2 = load_image("tests/icons/icon_2.png") 12test_images_asset2 = load_image("tests/icons/icon_2.png")
13test_sounds_sound1 = load_sound("tests/sounds/effect1.wav")
14test_sounds_sound2 = load_sound("tests/sounds/song1.ogg")
15test_sounds_volume = 100
13 16
14function test_api() 17function test_api()
15 draw_rect(100, 100, 300, 200, color.YELLOW) 18 draw_rect(100, 100, 300, 200, color.YELLOW)
@@ -140,13 +143,28 @@ function test_camera()
140end 143end
141 144
142function test_images() 145function test_images()
143 draw_text(string.format("uid: %s", test_images_asset1), 50, 50, 20, color.VIOLET) 146 draw_text(string.format("uid: %s", test_images_asset1), 30, 30, 20, color.VIOLET)
144 draw_text(string.format("uid: %s", test_images_asset2), 50, 80, 20, color.VIOLET) 147 draw_text(string.format("uid: %s", test_images_asset2), 30, 55, 20, color.VIOLET)
145 148
146 draw_image(test_images_asset1, 150, 150) 149 draw_image(test_images_asset1, 150, 150)
147 draw_image(test_images_asset2, 200, 200) 150 draw_image(test_images_asset2, 200, 200)
148end 151end
149 152
153function test_sounds()
154 draw_text("Press button A to play a short sound effect.", 30, 30, 20, color.BLUE)
155 draw_text("Press button B to play a longer sound effect.", 30, 55, 20, color.BLUE)
156
157 if button_pressed(button.A) then
158 draw_text("Button A pressed", 30, 85, 20, color.YELLOW)
159 play_sound(test_sounds_sound1)
160 end
161
162 if button_pressed(button.B) then
163 draw_text("Button B pressed", 30, 85, 20, color.YELLOW)
164 play_sound(test_sounds_sound2)
165 end
166end
167
150while window_running() do 168while window_running() do
151 start_drawing() 169 start_drawing()
152 clear_window(color.BLACK) 170 clear_window(color.BLACK)
@@ -156,6 +174,7 @@ while window_running() do
156 -- test_buttons() 174 -- test_buttons()
157 -- test_camera() 175 -- test_camera()
158 -- test_images() 176 -- test_images()
177 -- test_sounds()
159 178
160 draw_info() 179 draw_info()
161 stop_drawing() 180 stop_drawing()