-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added background music #10
base: 8-add-music-to-game
Are you sure you want to change the base?
Conversation
…PS to 60 for smoother game.
Added Sound class to eliminate need for second pg.init(). Sound class can be used to play any other sounds in the game.
Added jump sound
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, sounds seem to work perfectly! Also thank you for fixing some of the code smells and naming conventions.
Just a few tiny things for improvement,
- If the music file is not found the game crashes with a FileNotFoundError, this might not be intended behaviour, maybe we could run the game without that sound and issue a warning in the console?
- Is it possible to turn down the background music by a bit? Its not terribly loud by I prefer it to be less prominent
- Can we add a "game over" sound?
Co-authored-by: Ido <benhaim.ido@gmail.com>
Thank you for the feedback. I added a game over sound and reduced the volume of the background music. Please let me know if the music is at a better volume now. I also did some handling for the FileNotFoundError, however I made it such that if one file is missing, there are no game sounds because I'm still trying to figure out how to determine which specific file is missing and handle it that way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no game sounds because I'm still trying to figure out how to determine which specific file is missing and handle it that way.
maybe we could have that logic in aloadSound(name, path)
method?
if not self.sound.no_music: | ||
self.sound.play('jump') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of logic should probably be in the sound class
sound = Sound() | ||
if not sound.no_music: | ||
sound.play('background_music') | ||
else: | ||
print("Warning: A Music file could not be found. The game will run without music.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put this logic in the sound class (play method)
@nitic04 any updates on this PR? |
Added the background music that plays when the game is launched. Also added the music file credit to the readme file.