         
         // Play torpedo sound when bullet is launched
         
-        do
-        {
-            if let torpedoURL = Bundle.main.url(forResource: "torpedo", withExtension: "mp3") {
-            
-            try player = AVAudioPlayer(contentsOf: torpedoURL)
-            player.play()
-                
-            }
-        }
-        catch let error as NSError {
-            print(error.description)
-        }
-        
+        self.playSoundEffect(ofType: .torpedo)
         
         let bulletsNode = Bullet()
         

        
        // Play collision sound for all collisions (bullet-bullet, etc.)
        
        do
        {
            if let collisionURL = Bundle.main.url(forResource: "collision", withExtension: "mp3") {
                
                try player = AVAudioPlayer(contentsOf: collisionURL)
                player.play()
                
            }
        }
        catch let error as NSError {
            print(error.description)
        }
        
        if explosion {
            
            // Play explosion sound for bullet-ship collisions
            
            do
            {
                if let explosionURL = Bundle.main.url(forResource: "explosion", withExtension: "mp3") {
                    
                    try player = AVAudioPlayer(contentsOf: explosionURL)
                    player.play()
                    
                }

        }
    }
}

enum SoundEffect: String {
    case explosion = "explosion"
    case collision = "collision"
    case torpedo = "torpedo"
}
