-
Notifications
You must be signed in to change notification settings - Fork 20
More Sounds
In this part, more sound effects are added.
Freesound is a collaborative database of Creative Commons Licensed sounds and a good place to look for sound effects.
Apart from music, sounds have been played only on ball-brick collisions. Besides, there has been only a single sound for each brick type. To add some diversity, I want to add sound effect to other collision types, and I want several effects for each event.
First, more sounds on ball-brick collisions:
local simple_break_sound = {
love.audio.newSource(
"sounds/simple_break/recordered_glass_norm.ogg",
"static"),
love.audio.newSource(
"sounds/simple_break/edgardedition_glass_hit_norm.ogg",
"static") }
local armored_hit_sound = {
love.audio.newSource(
"sounds/armored_hit/qubodupImpactMetal_short_norm.ogg",
"static"),
love.audio.newSource(
"sounds/armored_hit/cast_iron_clangs_14_short_norm.ogg",
"static"),
love.audio.newSource(
"sounds/armored_hit/cast_iron_clangs_22_short_norm.ogg",
"static") }
local armored_break_sound = {
love.audio.newSource(
"sounds/armored_break/armored_glass_break_short_norm.ogg",
"static"),
love.audio.newSource(
"sounds/armored_break/ngruber__breaking-glass_6_short_norm.ogg",
"static") }
local ball_heavyarmored_sound = {
love.audio.newSource(
"sounds/heavyarmored_hit/cast_iron_clangs_11_short_norm.ogg",
"static"),
love.audio.newSource(
"sounds/heavyarmored_hit/cast_iron_clangs_18_short_norm.ogg",
"static") }
Sounds when bonus is picked.
local bonus_collected_sound = {
love.audio.newSource("sounds/bonus/bonus1.wav", "static"),
love.audio.newSource("sounds/bonus/bonus2.wav", "static"),
love.audio.newSource("sounds/bonus/bonus3.wav", "static")
}
Ball-wall collision sound effect.
local ball_wall_sound = love.audio.newSource(
"sounds/ball_wall/pumpkin_break_01_short_norm.ogg",
"static")
After loading the sounds, it is necessary to select and play one of them. To select one of the sounds, random number generator is created. After that, it is queried on each event.
Bricks.
local snd_rng = love.math.newRandomGenerator( os.time() )
function bricks.brick_hit_by_ball( i, brick, shift_ball, bonuses, score_display )
if bricks.is_simple( brick ) then
.....
table.remove( bricks.current_level_bricks, i )
local snd = simple_break_sound[ snd_rng:random( #simple_break_sound ) ]
snd:play()
elseif bricks.is_armored( brick ) then
bricks.armored_to_scrathed( brick )
local snd = armored_hit_sound[ snd_rng:random( #armored_hit_sound ) ]
snd:play()
elseif bricks.is_scratched( brick ) then
bricks.scrathed_to_cracked( brick )
local snd = armored_hit_sound[ snd_rng:random( #armored_hit_sound ) ]
snd:play()
elseif bricks.is_cracked( brick ) then
.....
table.remove( bricks.current_level_bricks, i )
local snd = armored_break_sound[ snd_rng:random( #armored_break_sound ) ]
snd:play()
elseif bricks.is_heavyarmored( brick ) then
local snd =
ball_heavyarmored_sound[ snd_rng:random( #ball_heavyarmored_sound ) ]
snd:play()
end
end
Same for the bonuses:
local snd_rng = love.math.newRandomGenerator( os.time() )
function bonuses.bonus_collected( i, bonus,
balls, platform,
walls, lives_display )
.....
table.remove( bonuses.current_level_bonuses, i )
local snd = bonus_collected_sound[ snd_rng:random( #bonus_collected_sound ) ]
snd:play()
end
Since there is only a single sound for the ball-wall collision, there is no need for random number generator.
function balls.wall_rebound( single_ball, shift_ball )
.....
balls.increase_speed_after_collision( single_ball )
ball_wall_sound:play()
end
Feedback is crucial to improve the tutorial!
Let me know if you have any questions, critique, suggestions or just any other ideas.
Chapter 1: Prototype
- The Ball, The Brick, The Platform
- Game Objects as Lua Tables
- Bricks and Walls
- Detecting Collisions
- Resolving Collisions
- Levels
Appendix A: Storing Levels as Strings
Appendix B: Optimized Collision Detection (draft)
Chapter 2: General Code Structure
- Splitting Code into Several Files
- Loading Levels from Files
- Straightforward Gamestates
- Advanced Gamestates
- Basic Tiles
- Different Brick Types
- Basic Sound
- Game Over
Appendix C: Stricter Modules (draft)
Appendix D-1: Intro to Classes (draft)
Appendix D-2: Chapter 2 Using Classes.
Chapter 3 (deprecated): Details
- Improved Ball Rebounds
- Ball Launch From Platform (Two Objects Moving Together)
- Mouse Controls
- Spawning Bonuses
- Bonus Effects
- Glue Bonus
- Add New Ball Bonus
- Life and Next Level Bonuses
- Random Bonuses
- Menu Buttons
- Wall Tiles
- Side Panel
- Score
- Fonts
- More Sounds
- Final Screen
- Packaging
Appendix D: GUI Layouts
Appendix E: Love-release and Love.js
Beyond Programming: