A lot of options here. For now, we will use this tutorial project to teach the fundamentals. Don't be expecting to convert this simple project into your awesome game at some point.
Name your project Tutorial and save it wherever you like. If none of this has shown up, XNA game studio may not have been installed correctly (or it might not be installed at all). Make sure you installed all the components correctly if this is the case.
The first thing your project should open is a class titled Game1 . This is your main game loop, and is effectively the first thing that is run when your code starts (actually it's the second, but I'll get into that at the end). Lets look at the methods contained in Game1 :Also note that Game1 extends Microsoft.Xna.Framework.Game , and all of these methods are overrides of methods contained in the parent class (right click the "Game" in Microsoft.Xna.Framework.Game and select Go To Definition to see them all. Doing this with any class will open that class in a new tab).
- Initialize() - base.initialize() will initialize all the components of the parent class (see below).
- LoadContent() - Called at the game's start to preload any necessary content
- UnloadContent() - Called at the game's end to unload all content (no touchy)
- Update(GameTime gameTime) - all updates to the game's internal logic should be done from this method.
- Draw(GameTime gameTime) - all calls to change the game's drawn sprites should come form here.
I'm going to digress here for a moment. Effectively, any videogame needs to perform three critical operations to be considered a videogame.
Think about it; so long as it performs this loop a few dozen times a second, this is the simplest program architecture all videogames are composed of.
Our Game1 class contains two of these methods (Update() and Draw()), and in fact, both of them don't contain any content in them. They're just explicitly stated- empty called methods (well, they're not fully empty, but you get my drift).
As you can tell, we got a lot of work to do. Our next lesson will cover making a class to procure keyboard input. Before we end today however, go to the title bar and select Debug, and then select Start Debugging. If you didn't change anything just yet, the solution should build and a new window should pop up.
Cornflower Blue. Classy.
At least we have a window showing up. Microsoft completed most of our boilerplate code for us, and the nastier bits we would normally have to slog through are taken care of further up the class hierarchy (we're not allowed to see what's going on under the hood, so for now assume it operates on principles of magic and unicorns).
HOMEWORK: Find where in the Game1 code the background is set to the light blue, and change it to black. Save and exit.
Post a Comment