Independent Study

I'm working on a breakdown of the Spacewar demo game that comes packaged with the XNA beta.


The game is run by Spacewar Game.cs with a heavy reliance on the System and Framework files stored in the References directory of the game. I highly recommend using the Object Browser in XNA when trying to orient yourself in the project: a tree list expands through the files and summarized code within those files in a visual format. Helps also to see where System/Framework calls are going and what happens when they are called.

Spacewar Game.cs is where the general structure resides and is expanded below.


The main game file is Spacewar Game.cs. Below is a summary breakdown of the internal elements.

Spacewar Game.cs
using brings in framework and system files which are standard to most games
namespace Spacewar
class Spacewar
This is the main game program location.
public static someVariableName ... there are a bunch of these
The series of statements set global variables in the game. For Spacewar, these are mostly containers into which other elements will be placed later. Special note here: settings should not be set in this area, as the settings file (see below, settings.rhtml) is read in after this file (Spacewar Game.cs), and so any settings placed here which are also in the settings file will be overwritten by the values in the settings file.
SpacewarGame()
This is the game initialization, or the constructor for the Spacewar game class.
WindowsGame_Exiting
Triggered to dump font when game exits.
WindowsGame_Starting
Triggered when game starts. Loads the settings from settings.rhtml, start up music, set up splash screen, and installs an event handler for the device created event to allow update of graphcis resources.
update
Checks to reload the settings or update the game state.
draw
Renders all of the graphcis elements on the screen.
ChangeState
Controls the settings needed for each GameState. Chain of if statements branch down into each possible state, where the states roughly translate to the different screens the player sees in the game (splash screen, selecting ships screen, retro game playing screen, etc.)
graphics_DeviceCreated
Called when initializing the graphics device back up in WindowsGame_Starting().


Copyright © 2008 | B. Steiner
britsteiner@gmail.com | updated: 2/16/2008

Home

Portfolio

Resume

Games, Simulation, & Society

SDE Senior Seminar

Independent
Study