In this Quora answer, I suggested a few ways that games can be used to teach advanced subjects. For example:
[To learn] programming, one can be required to create programs to complete missions.
I recently came across a mention in the WSJ of a game that will do exactly that. From the website of CodeHero:
You can edit new code to do anything you can imagine. You'll learn how to blast the enemy, manipulate the world, and build structures creatively to create the games of your dreams and recruit an army of coders to save the world from rogue AI.