1-- GunFu Deadlands 2-- Copyright 2009-2011 Christiaan Janssen, September 2009-October 2011 3-- 4-- This file is part of GunFu Deadlands. 5-- 6-- GunFu Deadlands is free software: you can redistribute it and/or modify 7-- it under the terms of the GNU General Public License as published by 8-- the Free Software Foundation, either version 3 of the License, or 9-- (at your option) any later version. 10-- 11-- GunFu Deadlands is distributed in the hope that it will be useful, 12-- but WITHOUT ANY WARRANTY; without even the implied warranty of 13-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14-- GNU General Public License for more details. 15-- 16-- You should have received a copy of the GNU General Public License 17-- along with GunFu Deadlands. If not, see <http://www.gnu.org/licenses/>. 18 19Sounds = { 20 21 bullet_time = love.audio.newSource("sounds/explosion.ogg","static"), 22 23 revolver = { 24 love.audio.newSource("sounds/Revolver_shot1.ogg","static"), 25 love.audio.newSource("sounds/Revolver_shot2.ogg","static"), 26 }, 27 28 revolver_slow = { 29 love.audio.newSource("sounds/Revolver_shot1_slow.ogg","static"), 30 love.audio.newSource("sounds/Revolver_shot2_slow.ogg","static"), 31 }, 32 33 shot_blue = { 34 normal = love.audio.newSource("sounds/Revolver_shot_blue.ogg","static"), 35 slow = love.audio.newSource("sounds/Revolver_shot_blue_slow.ogg","static"), 36 }, 37 38 shot_red = { 39 normal = love.audio.newSource("sounds/Revolver_shot_red.ogg","static"), 40 slow = love.audio.newSource("sounds/Revolver_shot_red_slow.ogg","static"), 41 }, 42 43 shot_green = { 44 normal = love.audio.newSource("sounds/Revolver_shot_green.ogg","static"), 45 slow = love.audio.newSource("sounds/Revolver_shot_green_slow.ogg","static"), 46 }, 47 48 shot_yellow = { 49 normal = love.audio.newSource("sounds/Revolver_shot_yellow.ogg","static"), 50 slow = love.audio.newSource("sounds/Revolver_shot_yellow_slow.ogg","static"), 51 }, 52 53 scream_blue = { 54 love.audio.newSource("sounds/scream_blue1.ogg","static"), 55 love.audio.newSource("sounds/scream_blue2.ogg","static"), 56 }, 57 58 scream_blue_slow = { 59 love.audio.newSource("sounds/scream_blue_slow1.ogg","static"), 60 love.audio.newSource("sounds/scream_blue_slow2.ogg","static"), 61 }, 62 63 scream_red = { 64 love.audio.newSource("sounds/scream_red1.ogg","static"), 65 love.audio.newSource("sounds/scream_red2.ogg","static"), 66 }, 67 68 scream_red_slow = { 69 love.audio.newSource("sounds/scream_red_slow1.ogg","static"), 70 love.audio.newSource("sounds/scream_red_slow2.ogg","static"), 71 }, 72 73 scream_yellow = { 74 love.audio.newSource("sounds/scream_yellow.ogg","static"), 75 }, 76 77 scream_yellow_slow = { 78 love.audio.newSource("sounds/scream_yellow_slow.ogg","static"), 79 }, 80 81 scream_green = { 82 love.audio.newSource("sounds/scream_green.ogg","static"), 83 }, 84 85 scream_green_slow = { 86 love.audio.newSource("sounds/scream_green_slow.ogg","static"), 87 }, 88 89 scream_player = love.audio.newSource("sounds/scream_player.ogg","static"), 90 91 reload_start = love.audio.newSource("sounds/reload_start.ogg","static"), 92 reload_done = love.audio.newSource("sounds/reload_done.ogg","static"), 93 reload_start_slow = love.audio.newSource("sounds/reload_start_slow.ogg","static"), 94 reload_done_slow = love.audio.newSource("sounds/reload_done_slow.ogg","static"), 95 96} 97 98Sounds.active = true 99 100function Sounds.playsound( sound ) 101 love.audio.stop( sound ) 102 love.audio.rewind( sound ) 103 love.audio.play( sound ) 104end 105 106function Sounds.play_shot_player() 107 if not Sounds.active then return end 108 if not BulletTime.active then 109 Sounds.playsound(Sounds.revolver[math.random(table.getn(Sounds.revolver))]) 110 else 111 Sounds.playsound(Sounds.revolver_slow[math.random(table.getn(Sounds.revolver_slow))]) 112 end 113end 114 115function Sounds.play_shot_enemy( enemy ) 116 if not Sounds.active then return end 117 if not BulletTime.active then 118 Sounds.playsound(enemy.shot_sound.normal) 119 else 120 Sounds.playsound(enemy.shot_sound.slow) 121 end 122end 123 124function Sounds.play_bullettime() 125 if not Sounds.active then return end 126 Sounds.playsound(Sounds.bullet_time) 127end 128 129function Sounds.play_scream_enemy(enemy) 130 if not Sounds.active then return end 131 if not BulletTime.active then 132 Sounds.playsound(enemy.scream[math.random(table.getn(enemy.scream))]) 133 else 134 Sounds.playsound(enemy.scream_slow[math.random(table.getn(enemy.scream))]) 135 end 136end 137 138function Sounds.play_scream_player() 139 if not Sounds.active then return end 140 Sounds.playsound(Sounds.scream_player) 141end 142 143function Sounds.play_reload_start() 144 if not Sounds.active then return end 145 if not BulletTime.active then 146 Sounds.playsound(Sounds.reload_start) 147 else 148 Sounds.playsound(Sounds.reload_start_slow) 149 end 150end 151 152function Sounds.play_reload_done() 153 if not Sounds.active then return end 154 if not BulletTime.active then 155 Sounds.playsound(Sounds.reload_done) 156 else 157 Sounds.playsound(Sounds.reload_done_slow) 158 end 159end 160 161function Sounds.switch() 162 Sounds.active = not Sounds.active 163end 164 165Music={ 166 active = true, 167 maintheme = love.audio.newSource( 'music/GunFuMainTheme.ogg' ), 168} 169 170function Music.start() 171 Music.maintheme:setLooping(true) 172 Sounds.playsound( Music.maintheme ) 173end 174 175function Music.pause() 176 love.audio.pause( Music.maintheme ) 177 Music.active = false 178end 179 180function Music.continue() 181 love.audio.resume( Music.maintheme ) 182 Music.active = true 183end 184 185function Music.switch() 186 if Music.active then 187 Music.pause() 188 else 189 Music.continue() 190 end 191end 192 193