Game Programming Class1

esse quam videri
Revision as of 17:58, 14 December 2008 by Jeff (talk | contribs)
Jump to: navigation, search

Discuss Syllabus


What is XNA?


Why do we need it?

Why not use c++?

What is DirectX?

show c++ examples

<a href="">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


  • Start a new XNA Project

Add two varibale declareations at the top of the class

            Texture2D PacMan;
            Vector2 PacManLoc;


  • 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);
  • Add the following code to the Draw Method to Draw the texture
    			protected override void Draw(GameTime gameTime)
                // TODO: Add your drawing code here
                spriteBatch.Draw(PacMan, PacManLoc, Color.White);

    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=""> IntroSimpleSpriteWindows/Game1.cs </a> the build of the game will look like <img src="ClassSource/Images/IntroSimpleSpriteWindows.png">

    Simple 2D texture example with update