Difference between revisions of "Game Programming Class2"
esse quam videri
(→Homework) |
(→Homework) |
||
Line 91: | Line 91: | ||
*Sprite Class | *Sprite Class | ||
:Build a class that is reusable that can draw a single texture on the screen. Be sure to encapsulate all the properties and method that you need to draw the sprite. | :Build a class that is reusable that can draw a single texture on the screen. Be sure to encapsulate all the properties and method that you need to draw the sprite. | ||
+ | *Read Chapter 2 in XNA 3.0 | ||
==Links== | ==Links== |
Revision as of 19:40, 1 February 2009
Contents
Fonts
free game fonts XNA Redistributable Font Pack
in class
Spritefont demo
IntroFonts/Game1.cs IntroFonts.zip
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;
- Declare SpriteBatch spriteBatch;
- Initialize()
- LoadContent()
- UnloadContent()
- Update(GameTime gameTime)
GameTime
FrameRate and GameTime
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.
- Draw(GameTime gameTime)
Console And Trace
We will build a console class later and debug in game.
Texture2D and SpriteBatches
[2D Graphics Overview http://msdn.microsoft.com/en-us/library/bb203919.aspx]
About textures and Batching
Displays, ViewPorts, Client Bounds
Alpha channels
Demo
SpriteBacth
demo project
- IntroSimpleSpriteBatchOptionsWindows.zip
spriteBatch.Begin();
- Options SpriteBlendMode
- Additive Enable additive blending. http://blogs.msdn.com/etayrien/archive/2006/12/19/alpha-blending-part-3.aspx
- AlphaBlend Enable alpha blending. http://blogs.msdn.com/etayrien/archive/2006/12/19/alpha-blending-part-2.aspx
- None No blending specified.
Other Projects
IntroSimpleSpriteUpdateGravityWindows.zip IntroSimpleSpriteUpdateWindows.zip
Homework
- XNA Picture With Update
- Update you picture to include some movement with the update method.
- Sprite Class
- Build a class that is reusable that can draw a single texture on the screen. Be sure to encapsulate all the properties and method that you need to draw the sprite.
- Read Chapter 2 in XNA 3.0