Difference between revisions of "Game Programming Class1"
(→Discuss Syllabus) |
(→Discuss Syllabus) |
||
Line 4: | Line 4: | ||
*Visual Studio 2010 available from MSDN | *Visual Studio 2010 available from MSDN | ||
**In VS2012 you need to do some extra steps | **In VS2012 you need to do some extra steps | ||
− | |||
***http://ryan-lange.com/xna-game-studio-4-0-visual-studio-2012/ | ***http://ryan-lange.com/xna-game-studio-4-0-visual-studio-2012/ | ||
+ | **In windows8 you need more extra steps | ||
+ | *** http://answers.microsoft.com/en-us/windows/forum/windows_cp-windows_programs/xna-game-studio-4-fails-to-install/b4b9b277-eb60-41dd-8a17-0c3020253ebc | ||
+ | |||
*XNA 4.0 http://create.msdn.com/en-us/home/getting_started | *XNA 4.0 http://create.msdn.com/en-us/home/getting_started | ||
**requirements http://msdn.microsoft.com/en-us/library/bb203925.aspx | **requirements http://msdn.microsoft.com/en-us/library/bb203925.aspx |
Revision as of 22:31, 9 January 2013
Contents
Discuss Syllabus
Software
- Visual Studio 2010 available from MSDN
- In VS2012 you need to do some extra steps
- In windows8 you need more extra steps
- XNA 4.0 http://create.msdn.com/en-us/home/getting_started
- DirectX SDK http://msdn.microsoft.com/en-us/directx/aa937788.aspx
What is XNA?
Discussion
Why do we need it?
Why not use c++?
Major changes in XNA 4
- What's new http://msdn.microsoft.com/en-us/library/bb417503.aspx
- Graphics Profiles
- Reach HLSL 2.0
- HiDef HLSL 3.0 platform showcase features
What is DirectX?
show c++ examples
Hello World
Hello World in XNA 4.0 using spritefont. We'll revisit the spriteFont when we build the console/debug class
Hello XNA with texture
Simple xna project that draws a pacman sprite
- Start a new XNA Project
Add two variable declarations at the top of the class <csharp>
Texture2D PacMan; Vector2 PacManLoc;
</csharp>
In the LoadContent
Function add the following code to initialize the two variables declared above
<csharp>
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 //load PacMan image PacMan = Content.Load<texture2d>("pacmanSingle"); //Center PacMan image PacManLoc = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); }
</csharp>
- Add the following code to the Draw Method to Draw the texture
<csharp> 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); }
</csharp> pacman image is availble here:
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
HomeWork
Install VS2010 get XNA 4 http://www.microsoft.com/download/en/details.aspx?id=23714
Create an XNA Picture. The picture needs to have at least
- 1 SpriteFont
- 3 Textures
Also please post a screen shot of your project running in the assignments. Zip and upload source to blackboard.
You can take a screen shot using the snip tool. Start run snip in vista or 7. Or you can just press the Print Screen key on the keyboard.