Anatomy of An XNA Game

Category: Entertainment

Presentation Description

No description available.


Presentation Transcript

Anatomy of An XNA Game:

Computer Games Development Anatomy of An XNA Game


Game1.cs This is the default class for an XNA game, it is created when you create and XNA project. There are five primary methods you will customize for any XNA project: The C onstructor :- Game1() Initialize() LoadContent () Update() Draw()


Declarations Below the class declaration for Game1 is the class level declarations area. By default, this area contains two variables: GraphicsDeviceManager graphics; SpriteBatch spriteBatch ; The graphics object provides access to, not surprisingly, the system's video card XNA provides the SpriteBatch class to allow you to draw 2D images ( called sprites) to the screen. The declarations area where you declare variables for data you will be accessing during the game

The constructor:

The constructor The constructor creates a new gamen and is the first thing that happens when our XNA game is executed. The class constructor is identified as public Game1(), and by default , it contains only two lines : graphics = new GraphicsDeviceManager (this); Content.RootDirectory = "Content";


Initialize() When an XNA game begins to run, the Initialize() method is called. This method only runs once, The Initialize() method is the ideal place to set up things like the screen resolution, toggle full screen mode, and enable the mouse in a Windows project.


Load_Content () The method is used to read in any graphical and audio resources your game will need.


Update() An XNA game calls the Update() method 60 times per second . All of your game logic gets built into the Update() method. It is here that you check for player input, move sprites, spawn enemies, track scores etc etc


Draw() The final method in the default Game1.cs file is responsible, not surprisingly, for drawing the current game state to the display. Draw () is normally called once after each call to Update ()

authorStream Live Help