Super Mario 64 is set in Princess Peach's Castle, which consists of three floors, a basement, a moat, and a courtyard. The area outside the castle is an introductory area in which the player can experiment, testing his or her player skills. Scattered throughout the castle are entrances to courses via secret walls and paintings.
Super Mario 64 begins with a letter from Princess Peach inviting Mario to come to her castle for a cake she has baked for him. However, when he arrives, Mario discovers that Bowser has invaded the castle and imprisoned the princess and her servants within it using the power of the castle's 120 Power Stars. Many of the castle's paintings are portals to other worlds, in which Bowser's minions keep watch over the stars. Mario explores the castle for these portals to enter the worlds and recover the stars. He gains access to more rooms as he recovers more Power Stars, and eventually traverses three different obstacle courses, each leading to its own battle with Bowser. Defeating Bowser the first two times earns Mario a key for opening another level of the castle. After Mario defeats Bowser in the final battle, Peach is released from the stained-glass window above the castle's entrance. Peach rewards Mario by kissing him and baking the cake that she had promised him.