I’m currently trying to use SDL_Mixer to load a .wav file for my game. I created a seperate header file where I put functions related to loading files, playing, freeing after use,… and also load the sound file in it.
audios.h:
Mix_Chunk* batSound = nullptr;
void init () {
initSDL ();
batSound = loadSound("bat.wav");
}
void play(Mix_Chunk* gChunk) {
if (gChunk != nullptr) {
Mix_PlayChannel( -1, gChunk, 0 );
}
}
main.cpp:
Audios audio;
audio.play(audio.batSound);
and it worked fine, just not in the “design” I want. So I moved it to the file where I code my game/logic movement (“logics.h)” for more precise design but it doesnt play anymore.
Please help. My deadline is near:(