The code, art, and other elements that make up a game are not tangible items like, say, a car. They are known as “intellectual property” (IP). This goes for stories, concepts, and so on. A very specific branch of law deals with intellectual property and lawyers who specialize in it will be the folks to turn to when you discuss publishing or distributing your game. Selling your game to a publisher means that you are also selling the IP involved with the game. All of this must be laid out in the contracts involved with publishing.
Another factor regarding IP in your game involves the individual employees working for you. Make sure that it is written in their employee contracts that all IP made by them ...