Game Programming Class1

esse quam videri
Revision as of 18:22, 25 January 2016 by Jeff (talk | contribs) (Text replacement - "</csharp>" to "</syntaxhighlight>")
Jump to: navigation, search

Discuss Syllabus


GitHuib URL

Mono Game

Installing Monogame

What is DirectX?

show c++ examples

quick start guide - create

watch Accelerating Windows Store Game Development with Middleware

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

2             Texture2D PacMan;
3             Vector2 PacManLoc;

In the LoadContent Function add the following code to initialize the two variables declared above

 1         protected override void LoadContent()
 2         {
 3             // Create a new SpriteBatch, which can be used to draw textures.
 4             spriteBatch = new SpriteBatch(GraphicsDevice);
 6             // TODO: use this.Content to load your game content here
 7             //load PacMan image
 8             PacMan = Content.Load<texture2d>("pacmanSingle");
 9             //Center PacMan image
10             PacManLoc = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2);
11         }
  • Add the following code to the Draw Method to Draw the texture
 1 	protected override void Draw(GameTime gameTime)
 2         {
 3             graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
 5             // TODO: Add your drawing code here
 6             spriteBatch.Begin();
 7             spriteBatch.Draw(PacMan, PacManLoc, Color.White);
 8             spriteBatch.End();
10             base.Draw(gameTime);
11         }

pacman image is availble here: PacmanSingle.png

the full game1.cs file should look like

[ IntroSimpleSpriteWindows/Game1.cs]

the build of the game will look like IntroSimpleSpriteWindows.png

Simple 2D texture example with update


Watch Accelerating Windows Store Game Development with Middleware

Install VS2010 get XNA 4 or Install VS 2012 with Monogame 3.0.1

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 moodle.

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.