From 28f955f6de048d5e210171deb7852350a859ea3c Mon Sep 17 00:00:00 2001
From: talha <sarcxd@gmail.com>
Date: Mon, 3 Feb 2025 23:54:56 +0500
Subject: Added basic audio playback

---
 source/main.cpp | 20 ++++++++++++++++++--
 source/todo.txt |  2 +-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/source/main.cpp b/source/main.cpp
index ca9e71a..5ebfcc2 100755
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -1124,16 +1124,26 @@ int main(int argc, char* argv[])
 
   FrameTimer timer = frametimer();
 
-  // @section: audio
+  // @section: audio_setup
   ma_result result;
   ma_engine engine;
 
   result = ma_engine_init(NULL, &engine);
   if (result != MA_SUCCESS) {
+      SDL_Log("Failed to initialise audio engine\n");
       return -1;
   }
 
-  ma_engine_play_sound(&engine, "assets/audio/winds_of_stories.mp3", NULL);
+  // @resume: playing around with audio
+  ma_sound sound;
+  const char *sound_path = "assets/audio/Click_Soft_01.mp3";
+  result = ma_sound_init_from_file(&engine, sound_path, 0, NULL, NULL, &sound);
+  if (result != MA_SUCCESS) {
+      SDL_Log("Failed to load sound: %s\n", sound_path);
+      return -1;
+  }
+  //ma_sound_set_pitch(&sound, 1.5f);
+  //ma_sound_set_looping(&sound, 1);
 
   while (game_running) 
   {
@@ -1593,6 +1603,12 @@ int main(int argc, char* argv[])
     }
     
     // output
+
+    // @section: audio 
+    if (controller.jump) {
+	ma_sound_start(&sound);
+    }
+
     glClearColor(0.8f, 0.5f, 0.7f, 1.0f);
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
diff --git a/source/todo.txt b/source/todo.txt
index a3dfe48..6219117 100644
--- a/source/todo.txt
+++ b/source/todo.txt
@@ -28,7 +28,7 @@ DONE:
 in the level file.
 
 DOING:
-- Audio
+- Audio: figure out what the correct audio sound for jumping will be.
 
 TODO:
 - Gameplay programming with levels
-- 
cgit v1.2.3