Difference between revisions of "Game Programming Class2"

esse quam videri
Jump to: navigation, search
(SpriteBacth)
Line 4: Line 4:
 
The XNA Game class has two private properties
 
The XNA Game class has two private properties
 
*GraphicsDeviceManager graphics;
 
*GraphicsDeviceManager graphics;
*ContentManager contect;
+
*ContentManager content;
  
 
<pre>
 
<pre>
 
//the game constuctor can be used to set some graphics settings.
 
//the game constuctor can be used to set some graphics settings.
graphics.PreferredBackBufferHeight = 768;
+
graphics.PreferredBackBufferHeight = 768;
 
graphics.PreferredBackBufferWidth = 1024;
 
graphics.PreferredBackBufferWidth = 1024;
 
//graphics.PreferredBackBufferHeight = 1080;
 
//graphics.PreferredBackBufferHeight = 1080;
Line 24: Line 24:
 
==GameTime==
 
==GameTime==
 
FrameRate and GameTime
 
FrameRate and GameTime
 +
[http://msdn.microsoft.com/en-us/library/bb203873.aspx#ID2EYB Game Loop Timing]
 +
[http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gametime_members.aspx Game Time Members]
  
 
===Time and Timespan===
 
===Time and Timespan===

Revision as of 19:21, 18 January 2009

XNA Structures

Game Class

The XNA Game class has two private properties

  • GraphicsDeviceManager graphics;
  • ContentManager content;
//the game constuctor can be used to set some graphics settings.
graphics.PreferredBackBufferHeight = 768;
graphics.PreferredBackBufferWidth = 1024;
//graphics.PreferredBackBufferHeight = 1080;
//graphics.PreferredBackBufferWidth = 1920;
//graphics.IsFullScreen = true;


  1. Declare SpriteBatch spriteBatch;
  2. Initialize()
  3. LoadContent()
  4. UnloadContent()
  5. Update(GameTime gameTime)

GameTime

FrameRate and GameTime Game Loop Timing Game Time Members

Time and Timespan

Example of update using GameTime to calculate elapsed time IntroSimpleSpriteUpdateWindows.zip IntroSimpleSpriteWindows/Game1.cs

Understanding GameTime We'll revisit game time when we talk about performance profiling.

  1. Draw(GameTime gameTime)

Console And Trace

We will build a console class later and debug in game.

Texture2D and SpriteBatches

About textures...

Alpha channels

Demo Gimp http://gimp.org Paint.NET http://www.getpaint.net/

SpriteBacth

demo project IntroSimpleSpriteBatchOptionsWindows.zip

spriteBatch.Begin();

IntroSpriteModesDemo.png

  1. Options SpriteBlendMode
  2. Additive Enable additive blending. http://blogs.msdn.com/etayrien/archive/2006/12/19/alpha-blending-part-3.aspx
  3. AlphaBlend Enable alpha blending. http://blogs.msdn.com/etayrien/archive/2006/12/19/alpha-blending-part-2.aspx
  4. None No blending specified.

Other Projects

IntroSimpleSpriteUpdateGravityWindows.zip IntroSimpleSpriteUpdateWindows.zip

Homework

XNA Picture

Draw me a picture using an XNA project. The picture should use at least 3 Texture2D objects. The full project and executable are due next week

Please post a web documented screen shot of your executable on you website. The screen shot should have a thumbnail 175 px wide, have you name, the course name, and the name of the picture. The thumbnail will like to a fullsize screen shot.