I am trying to create footstep sounds in sdl2. It plays fine but it ignores the sound that is already playing in the channel.
So when I move the player the footstep sound plays like a machine gun(it overplays itself).
//Declaration
Mix_chunk* footstep = Mix_LoadWAV("Path/to/sound.wav");
//Current usage
while (gameLoop)
{
if (Player.hasMoved==true)
{
Mix_PlayChannel(-1,footstep,0);//the sound keeps playing even if the channel is still busy
}
}
In pygame I could easily use get_busy()
method. It should be easy to use in SDL2 too since pygame is using it.
//IDEAL usage
while (gameLoop)
{
if (Player.hasMoved==true)
{
if (ChannelFinishedPlaying(-1)==true)
{
Mix_PlayChannel(-1,footstep,0);
}
}
}