Skip to content

More Sounds

noooway edited this page Jun 6, 2017 · 23 revisions

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.

So far, 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, sound effects for other collision types can be implemented and instead of a single sound, several effects for each collision event can be provided to choose from.

I'll continue to use love.audio.Sources directly. However, several modules, such as SLAM and TEsound are available to simplify sound management. Check out another possibilities at the libraries list on the LÖVE wiki.

New sounds for ball-brick collisions are grouped in tables according to brick type:

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:

local ball_wall_sound = love.audio.newSource(
   "sounds/ball_wall/pumpkin_break_01_short_norm.ogg",
   "static")

After the sounds are loaded, it is necessary to select and play one of them. Selection is random, and several random number generators are created specially for this purpose.

For ball-brick collisions:

local snd_rng = love.math.newRandomGenerator( os.time() )                      --(*1)

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 ) ]  --(*2)
      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

(*1): New random number generator
(*2): snd_rng:random( #simple_break_sound ) generates a random number between 1 and the length of the simple_break_sound. This number is passed as an index into the simple_break_sound[ ..... ], which effectively selects a random element from the simple_break_sound

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 ball-wall collisions, 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

    Home
    Acknowledgements
    Todo

Chapter 1: Prototype

  1. The Ball, The Brick, The Platform
  2. Game Objects as Lua Tables
  3. Bricks and Walls
  4. Detecting Collisions
  5. Resolving Collisions
  6. Levels

    Appendix A: Storing Levels as Strings
    Appendix B: Optimized Collision Detection (draft)

Chapter 2: General Code Structure

  1. Splitting Code into Several Files
  2. Loading Levels from Files
  3. Straightforward Gamestates
  4. Advanced Gamestates
  5. Basic Tiles
  6. Different Brick Types
  7. Basic Sound
  8. 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

  1. Improved Ball Rebounds
  2. Ball Launch From Platform (Two Objects Moving Together)
  3. Mouse Controls
  4. Spawning Bonuses
  5. Bonus Effects
  6. Glue Bonus
  7. Add New Ball Bonus
  8. Life and Next Level Bonuses
  9. Random Bonuses
  10. Menu Buttons
  11. Wall Tiles
  12. Side Panel
  13. Score
  14. Fonts
  15. More Sounds
  16. Final Screen
  17. Packaging

    Appendix D: GUI Layouts
    Appendix E: Love-release and Love.js

Beyond Programming:

  1. Game Design
  2. Minimal Marketing (draft)
  3. Finding a Team (draft)

Archive

Clone this wiki locally