Difference between revisions of "Game Programming Class2"
(→Alpha channels) |
|||
Line 42: | Line 42: | ||
==Texture2D and SpriteBatches== | ==Texture2D and SpriteBatches== | ||
− | About textures... | + | |
+ | '''[2D Graphics Overview http://msdn.microsoft.com/en-us/library/bb203919.aspx]''' | ||
+ | |||
+ | About textures and Batching | ||
+ | |||
+ | [http://msdn.microsoft.com/en-us/library/bb203889.aspx Displays, ViewPorts, Client Bounds] | ||
+ | |||
===Alpha channels=== | ===Alpha channels=== | ||
Line 75: | Line 81: | ||
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. | 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. | ||
+ | |||
+ | ==Links== | ||
+ | [http://msdn.microsoft.com/en-us/library/bb194908.aspx How To: Draw a Sprite] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb203866.aspx How To: Animate a Sprite] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb203867.aspx How To: Draw a Masked Sprite over a Background] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb203868.aspx How To: Make a Scrolling Background] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb203869.aspx How To: Rotate a Sprite] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb194912.aspx How To: Rotate a Group of Sprites] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb194913.aspx How To: Scale a Sprite] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb194914.aspx How To: Tint a Sprite] | ||
+ | [http://msdn.microsoft.com/en-us/library/bb447674.aspx How To: Scale Sprites Based On Screen Size] |
Revision as of 19:34, 1 February 2009
Contents
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
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.
Links
How To: Draw a Sprite How To: Animate a Sprite How To: Draw a Masked Sprite over a Background How To: Make a Scrolling Background How To: Rotate a Sprite How To: Rotate a Group of Sprites How To: Scale a Sprite How To: Tint a Sprite How To: Scale Sprites Based On Screen Size