I've seen fan made games of Sonic, Mario, Zelda, etc.

What's the best method? Learning a programming language? How do you recreate the game mechanics?