This post is a portion of Part 14 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.
- 14.0 – Finishing Our Game
- 14.1 – Adding Game States to our Allegro 5 Game
- 14.2 – Adding a Background to our Allegro 5 Game
- 14.3 – Adding Audio to our Allegro 5 Game
- 14.4 – Deploying our Allegro 5 Game in Visual Studio 2010
Full source code can be found here.
I’m guessing there is no particular reason you chose to call play the boom sfx in both CollideBullet() and CollideComet() instead of just calling it in StartExplosion().
Is there a different add-on that is required to play .ogg? The song never plays and when I press the space bar to fire a bullet, it crashes the app with “Assertion failed: (spl), function al_play_sample, file /Users/username/allegro/addons/audio/kcm_sample.c, line 321.” (Xcode in OS X 10.7).
I even tried to use your code file and it still crashes the game and I am not sure why. As soon as I convert the files to .wmv format all problems disappear…..
Did you find an answer to this? I get the same error! I’m using .wav’s though.
Thanks.
It is a problem with the FireBullets() function. I commented out:
//al_play_sample(shot, 1, 0, 1, ALLEGRO_PLAYMODE_ONCE, 0);
Now the bullets fire, but without the sound of course.
Can anyone offer any help?
I lol’d at your “music”. It’s awesome.
If you want sounds that fit the game you can use these:
sfx can be downloaded from Imphenzia Soundtrack:
http://soundtrack.imphenzia.com/sound-effects/
I used “laser 043 (quick noise)” for my bullet sounds and “explosion 068 (loud quick blast kickback)” for my explosions.
These are available for free to be used in commercial or non-commercial games.
===
For background music you can use this:
http://freepd.com/Trance/Trance%20K%20Space%20Trance
It’s in public domain, so you can use it however you want.
This one is only available in mp3, but you can convert it to ogg using this software:
http://download.cnet.com/Free-MP3-WMA-OGG-Converter/3000-2140_4-10793572.html
That music puts Dr. Dre to shame. You should get your own headphones deal now. xD
Wouldn’t that be awesome!
Your answer was just what I neddee. It’s made my day!
What if we wanted to mute the music? I took a quick look at allegro5 audio addon manual and didn’t notice any function that could help.
use al_set_sample_instance_gain.
https://www.allegro.cc/manual/5/al_set_sample_instance_gain