mort8088 Just another WordPress site


XNA 3.x Adding Platformer Starter Kit to Network Game State Management

Originally posted 2009 - This was going to be a series of posts on making a game using the platformer starter kit, but I didn't think anyone liked this article so I didn't continue it, however from the number of hits I'm seeing and the fact that someone asked for this to be reposted, I might just look at this again but for XNA 4.0


This is the first part of many that should build up into a full platformer game that I could release on to XBLCG. As this is the first part I'm only explaining the steps for combining the starter kit that comes with XNA 3.0 with the Network Game State Management Sample from Creators Club Online. Future chapters will go into more detail about the code we're creating but for this one there is enough information out there on each of the two projects we are using.

My main reason for starting out with the two sample projects is that it will give us a head start on our whole project. We're not going to get bogged down with details like how to do the animation system, or the falling physics because they are already in to start with. We will be looking at ways to improve the game engine as we go, adding features, changing the data storage, changing the graphics and sound. For now let's just get the game running with a menu system...

Create a Platformer Starter Kit, compile it and exit, we're doing this is so that we have access to the content and code.

Extract the Network Game State Manager to a new directory.

Open the solution file from the Network Game State Manager folder you just created.

Expand the content sub project.

Add 5 new sub folders called :- Fonts, Graphics, Levels, Sounds, StateManager.

In the Graphics folder add 4 new sub folders called Backgrounds, Overlays, Sprites & Tiles.

Move the gamefont.spritefont & menufont.spritefont into the Fonts folder from the root of the content sub project.

Move the remaining files from the root of the content sub project into the StateManager folder.

Open an Explorer window at the SharedContent folder for the Platformer project you created in step 1 then open the Sounds folder.

Select all the WMA files and drag them over to the Sounds folder in your Solution Explorer, When you drop them on this folder they will be added to the solution.

Now in the Explorer window navigate up two directories and then into the HighResolutionContent Folder where you will find Backgrounds, Fonts, Levels, Overlays, Sprites & Tiles folders.

Open each of these directories and copy their contents into their corresponding folders in the Solution Explorer.

Add a new sub folder to the NetworkStateManagementWindows solution called GameClasses.

Go to your Explorer window, move back up from the Graphics folder to the main solution directory, here you need to select the following files :- Animation.cs, AnimationPlayer.cs, Circle.cs, Enemy.cs, Gem.cs, Level.cs, Player.cs, RectangleExtensions.cs, Tile.cs only.

Drag and drop these files on to the GameClasses folder, and they will be added to your solution.

Open up each of the files you just added and change the namespace line from

or what ever you called your temp solution back in step one, to

Why? So we dont have to add a using directive to the game file. VS2008 gives you a real easy way to do this see picture on left.

Expand Screens folder and open GamePlayScreen.cs ready for editing.

Remove the following lines from The fields region :-

And then add the following lines to the Fields region:-

Replace the LoadContent method with this :-

Replace the Update method with this :-

Replace HandlePlayerInput method with :-

[edit]A gotcha has been fixed with the continuePressed check, when you are using the keyboard for input, thanks to DarkChief for finding that one :-)[/edit]

Finaly replace the Draw method with this :-

Next you need to add some code to handle the HUD and Level re/loading copy the following code block in after the last method in the class :-

Next you need to jump back to the top of the file and add some using statements :-

Expand GameClasses folder and open Level.cs ready for editing.

Find the Constructor(in the Loading region-Why?) and change the first parameter type from


and the line just under it from


Expand the Levels folder in the content sub project, Select all three text files and change the Build Action property to None and the Copyto Output Directory to Copy if newer.

Press Ctrl+F to get the Find dialog box up, and enter "Content.Load<Texture2D>" in to the Find what: box and select "Entire Solution" from the Look in: dropdown & make sure the Match Case option is off. For each item you find alter the method parameter to point at it's new location EG :-


Sounds & Fonts should be unaffected....

[Edit]My mistake the line in ScreenManager.cs that loads in it's font, near line 115, needs updating from "menufont" to "fonts/menufont" thanks to Rives for pointing that one out :-)[/Edit]

Open Game.cs ready for editing from the solution root.

Go to the constructor method and find the lines that set up the screen resolution :-

And change them both to the following values :-

Now Compile and run the solution by pressing F5.

Job Done.

Let me know what you liked about this tutorial and what you didn't...

Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.