Game Programming Class4

esse quam videri
Revision as of 04:40, 9 February 2009 by Jeff (talk | contribs) (Sprite class)
Jump to: navigation, search

Came Components

About components Application Overview

Game Components are reusable and easy to add to a game Game Components

  • GameComponent Class
  • DrawGameComponent Class

http://blogs.msdn.com/xna/archive/2006/08/31/734204.aspx

Sprite class

IntroPacManComponent.zip

Project that refactors the pacman class into two classes

Sprite.cs DrawableSprite.cs

Then the pacman class can inherit from one of these two classes.

PacMan.cs

Due to the desire to limit the number of spritebatches, I've created two classes. The sprite class cannot draw itself without being associated with and external spritebatch. The DrawableSprite has it's own spritebatch which makes it easier to use but less efficient.

Console Class

Separate IntroGameLibrary Project to help Encapsulate Reusable Code. IntroConsole.zip IntoGameLibrary.zip

IntoGameLibrary/GameConsole.cs To Add the Component to the Game we make an delclare in the game class Then we need to add the componnet to the Game Components Collection.


<csharp>

       GameConsole gameConsole;
       public Game1()
       {
           graphics = new GraphicsDeviceManager(this);
           Content.RootDirectory = "Content";
           gameConsole = new GameConsole(this);
           this.Components.Add(gameConsole);
       }
           

</csharp>

IntroConsole/Game1.cs

Homework

Something