I'm going to simplify here, and also I'm not a lawyer etc etc etc. You should actually read these licenses if you're going to use them, and talking to a lawyer doesn't help either.
I'm assuming this is code you write yourself, and you will keep the copyright for it. When you use an open source license, you irrevocably grant other people the right to distribute your work possibly with certain strings attached, but for the licenses I'm familiar with, this does not take away the rights that you already have under copyright law. (ref: https://www.gnu.org/licenses/gpl-faq.html#DeveloperViolate)
Of course, if you incorporate code from third parties, you'll have to comply with the associated licensing terms.
The licenses I'm familiar with (mainly MIT, LGPL, and GPL) also do not prevent others from selling the code. GPL makes it difficult because the GPL would obligate anyone selling it to also offer source code and the rights to modify/redistribute it (and thus undercut the seller). LGPL has a weaker version of that, and MIT is a public domain equivalent license (i.e. give everyone all rights under copyright).
If you want to prevent others from redistributing your code (and making money from it), you can release the source code with your game but not offer any license to distribute it. Jason Rohrer did this with Inside a Star-filled Sky (ref: http://insideastarfilledsky.net/). If you just want to prevent other people from making money from it, Creative Commons BY-NC is good for that.
It really depends on what your goals are in releasing the source, and exactly what you want to allow people to do.