Game Development Reference
In-Depth Information
using Microsoft.Xna.Framework;
1
using Microsoft.Xna.Framework.Graphics;
2
3
4
class BasicGame : Game
{
5
GraphicsDeviceManager graphics;
6
SpriteBatch spriteBatch;
7
8
9
static void Main()
{
10
BasicGame game = new BasicGame();
11
game.Run();
12
}
13
14
15
public BasicGame()
{
16
Content.RootDirectory = "Content";
17
graphics = new GraphicsDeviceManager( this );
18
}
19
20
21
protected override void LoadContent()
{
22
spriteBatch = new SpriteBatch(GraphicsDevice);
23
}
24
25
26
protected override void Update(GameTime gameTime)
{
27
}
28
29
30
protected override void Draw(GameTime gameTime)
{
31
GraphicsDevice.Clear(Color.Olive);
32
}
33
}
34
Listing 3.1
A very basic game application
used for doing the things that are needed before the game application ends, such as
storing the updated high-score list, or closing the network connection. This means
that the basic set of methods to be supplied in an XNA game is (see also Fig. 3.1 ):
1. Initialize : here we can perform initialization tasks such as opening a network con-
nection or setting up an input device;
2. LoadContent : here we can load all the game assets, such as sprites, sounds, or
other assets needed for the game;
Search WWH ::




Custom Search