Difference between revisions of "Game Programming Class1"

esse quam videri
Jump to: navigation, search
(New page: ==Discuss Syllabus== <b>Software</b> *Visual Studio 2005 available from MSDN (VS2008 work with XNA 3.0 CTP but not with XNA 2.0)</li> *XNA 2.0 GSE <a href="http://creators.xna.com/en-US/d...)
 
Line 8: Line 8:
 
      
 
      
 
      
 
      
==What is XNA?==
+
==What is XNA?==
  
 
Discussion<br>
 
Discussion<br>
Line 24: Line 24:
 
<br>
 
<br>
  
==in class
+
==in class==
 
 
<p>Simple 2D texture demo</p>
+
<p>Simple 2D texture demo</p>
 
 
Simple xna project that draws a pacman sprite
+
Simple xna project that draws a pacman sprite
 
 
 
 
Demo
+
Demo
<li>Start a new XNA Project
+
*Start a new XNA Project
</li>
+
 
<li>
+
 
 +
Add two varibale declareations at the top of the class
  
Add two varibale declareations at the top of the class
+
<pre>
<pre> Texture2D PacMan;
+
            Texture2D PacMan;
 
             Vector2 PacManLoc;
 
             Vector2 PacManLoc;
 
</pre>
 
</pre>
Line 66: Line 67:
 
             base.Draw(gameTime);
 
             base.Draw(gameTime);
 
         }
 
         }
</pre></li>
+
</pre>
+
 
<br>
+
pacman image is availble @
<br>
+
<a href="http://brookfield.rice.iit.edu/jmeyers/ITM496-595/ClassSource/Content/pacman/png/pacmanSingle.png">pacmanSingle.png</a>
pacman image is availble @
 
<a href="http://brookfield.rice.iit.edu/jmeyers/ITM496-595/ClassSource/Content/pacman/png/pacmanSingle.png">
 
pacmanSingle.png</a>
 
<img src="http://brookfield.rice.iit.edu/jmeyers/ITM496-595/ClassSource/Content/pacman/png/pacmanSingle.png">
 
  
+
<img src="http://brookfield.rice.iit.edu/jmeyers/ITM496-595/ClassSource/Content/pacma/png/pacmanSingle.png">
the full game1.cs file should look like
+
the full game1.cs file should look like
<a href="http://brookfield.rice.iit.edu/jmeyers/gbrowser.php?file=/ITM496-595/ClassSource/Projects/IntroSimpleSpriteWindows/IntroSimpleSpriteWindows/Game1.cs">
+
<a href="http://brookfield.rice.iit.edu/jmeyers/gbrowser.php?file=/ITM496-595/ClassSource/Projects/IntroSimpleSpriteWindows/IntroSimpleSpriteWindows/Game1.cs">
IntroSimpleSpriteWindows/Game1.cs
+
IntroSimpleSpriteWindows/Game1.cs
</a>
+
</a>
+
the build of the game will look like
the build of the game will look like
+
<img src="ClassSource/Images/IntroSimpleSpriteWindows.png">
<img src="ClassSource/Images/IntroSimpleSpriteWindows.png">
 
 
 
 
 
<p>Simple 2D texture example with update</p>
+
<p>Simple 2D texture example with update</p>

Revision as of 17:58, 14 December 2008

Discuss Syllabus

Software


What is XNA?

Discussion

Why do we need it?

Why not use c++?

What is DirectX?

show c++ examples

<a href="http://creators.xna.com/en-US/create_detail">quick start guide - create</a>
How much c# do you know?

in class

Simple 2D texture demo

Simple xna project that draws a pacman sprite


Demo

  • Start a new XNA Project


Add two varibale declareations at the top of the class

            Texture2D PacMan;
            Vector2 PacManLoc;
			

</li>

  • In the Load_Content Funtion add the following code to initialize the two varibales 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);
            }</texture2d>
  • 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);
            }
    

    pacman image is availble @ <a href="pacmanSingle.png">pacmanSingle.png</a>

    <img src="pacmanSingle.png"> the full game1.cs file should look like <a href="http://brookfield.rice.iit.edu/jmeyers/gbrowser.php?file=/ITM496-595/ClassSource/Projects/IntroSimpleSpriteWindows/IntroSimpleSpriteWindows/Game1.cs"> IntroSimpleSpriteWindows/Game1.cs </a> the build of the game will look like <img src="ClassSource/Images/IntroSimpleSpriteWindows.png">


    Simple 2D texture example with update