Difference between revisions of "Game Programming Class1"
esse quam videri
m |
|||
Line 2: | Line 2: | ||
<b>Software</b> | <b>Software</b> | ||
− | *Visual Studio | + | *Visual Studio 2008 available from MSDN |
− | *XNA | + | *XNA 4.0 GSE http://creators.xna.com/en-US/downloads |
*Direct X SDK http://msdn.microsoft.com/en-us/directx/aa937788.aspx | *Direct X SDK http://msdn.microsoft.com/en-us/directx/aa937788.aspx | ||
Line 16: | Line 16: | ||
[http://creators.xna.com/en-US/create_detail quick start guide - create] | [http://creators.xna.com/en-US/create_detail quick start guide - create] | ||
− | + | ||
− | + | ==Hello World== | |
− | + | ||
+ | Hello World in XNA 3.0 using spritefont. We'll revisit the spritefont when we build the console/debug class | ||
==in class== | ==in class== | ||
Line 26: | Line 27: | ||
Simple xna project that draws a pacman sprite | Simple xna project that draws a pacman sprite | ||
− | |||
− | |||
==Demo== | ==Demo== |
Revision as of 19:14, 18 January 2009
Discuss Syllabus
Software
- Visual Studio 2008 available from MSDN
- XNA 4.0 GSE http://creators.xna.com/en-US/downloads
- Direct X SDK http://msdn.microsoft.com/en-us/directx/aa937788.aspx
What is XNA?
Discussion
Why do we need it?
Why not use c++?
What is DirectX?
show c++ examples
Hello World
Hello World in XNA 3.0 using spritefont. We'll revisit the spritefont when we build the console/debug class
in class
Simple 2D texture demo
Simple xna project that draws a pacman sprite
Demo
- Start a new XNA Project
Add two variable declarations at the top of the class
Texture2D PacMan; Vector2 PacManLoc;
In the Load_Content Funtion add the following code to initialize the two variables declared above
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here PacMan = Content.Load<texture2d>("pacmanSingle"); PacManLoc = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); }
- Add the following code to the Draw Method to Draw the texture
protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here spriteBatch.Begin(); spriteBatch.Draw(PacMan, PacManLoc, Color.White); spriteBatch.End(); base.Draw(gameTime); }
the full game1.cs file should look like
[http://brookfield.rice.iit.edu/jmeyers/gbrowser.php?file=/ITM496-595/ClassSource/Projects/IntroSimpleSpriteWindows/IntroSimpleSpriteWindows/Game1.cs IntroSimpleSpriteWindows/Game1.cs]
the build of the game will look like
Simple 2D texture example with update