No, actually you gain XP as you actively kill enemies each time you respawn. The object is to stay alive as much as you can and gain as much gold and XP as you can per run. Afterward, your next child (ie legacy) will start with that much money and use it towards upgrades. You slowly level while continually using money to unlock all the other upgrades in the game.
The Castle you build has all the classes in the game. Also you unlock status upgrades such as HP, magic, crit, and bag space (weight). You do these as you gain levels. Once you have unlocked enough classes shops appear in the main town. There are two primary shops, one for upgrading your physical attributes and another for upgrading your magic. You decide what's more important. I chose physical for HP, strength, and armor. But then later added some magic for intense damage from their special abilities. The choices is yours.
Oh by the way, you should start by growing the right side of your castle until you've unlocked the MINER class. This will next you the maximum gold per spawn.