Robot Foot Games Helping you improve your games as we improve our own. :)

30May/110

Saving where your player left off on PC

Save/Load feature in Platform Starter Kit. (Saves the player's position, so you can start where you left off) (NOTE: works with PC only)
UPDATE: You can find a tutorial for saving/loading on the 360 here: XNA 3.1 | XNA 4.0

In this tutorial I'm going to create a hotkey (S) that saves the player's current position into a text file. You can then use this text file when loading a level to have your player start where you left off. You could even combine this with the checkpoint tutorial, so if you save and quit you'll load at the last checkpoint you hit. Splicing things together is an awesome way to learn (for me at least) so I'll leave that to you.
At the top of Player.cs we need to add the following using statements:

 

In Player.cs add the following after Vector2 position:

 

Now in the Player constructor, add the following if/else statement, overwritting the current Reset method:

 

Now in the GetInput method we'll add a hotkey to save our game:

 

At the very bottom, I added the next couple methods, right after Draw().

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.