The only thing left to do is add in the music! This is easy to do and does not involve adding it a lot of lines of code. Before you start coding, you need to download all the music files that you want to add into the game. I decided to add in a score sound for when the score increases and a sound for when the game is over. I did not add in a background sound to run during when the game because I felt it was too much music but if you wanted to do it, it is done the exact same way as how i will be showing you to do the rest. You just have to search about for the one you are looking for but make sure you get them for free and don't have to sign up for an account to download anything. I'll leave the links below to the ones that I am using.
To add in the both the score and game over sound you only need to lines of code which are pygame.mixer.music.load('filename here')and pygame.mixer.music.play(0, 0.0). These lines of code load the music file into the game and then play it. For the score these lines of code need to be added in, in the else part of the if statement for the collision detection. For the game over sound, this code needs to be added in where you are terminating the game just above where you update it.
After that, it should all be working!
That is the game all finished! Hope it all worked out for you and my explaining of things was not too difficult.
Score sound - http://www.orangefreesounds.com/button-beep-tone/
Game over sound - http://www.orangefreesounds.com/funny-game-sound/
No comments:
Post a Comment