Can you imagine trying to become a writer without ever reading any books? It seems crazy. So why is it that so many people try to become programmers without ever reading any code?
There's a lot to be learned from other people's code, even if they aren't professional programmers. I've even picked up ideas from looking over assignments turned in by my students. It's amazing how many different ways there are to solve any given problem.
With this in mind, I thought it might be helpful to list a few open source games that you can look at for inspiration. Before we get started, keep in mind that even though these games are open source, they are not in the public domain.
That means you can't just copy and paste code from any of these projects unless you're willing to comply with their license. In the case of the GPL, that means you'll need to release the code for program as well.
Probably the most popular open source games are the Quake series from id Software. You can download the source to Quake 1, 2, and 3 from the id Software FTP server. Other first person shooters include Cube and it's "next-gen" offspring Sauerbraten.
Maybe you're more interested in making a 2D game. For platform games, check out the Super Mario Brothers clone Secret Maryo Chronicles. If you prefer strategy games, look at The Battle for Wesnoth and FreeCiv.
If none of the above games interest you, there are a few more places you can look. The Open Directory Project maintains a list of open source games. There is also a Sourceforge project called OSSwin that maintains a list of open source games for Windows.