Difference between revisions of "Game Programming Class2"

esse quam videri
Jump to: navigation, search
(SVN Checkout)
m (Text replacement - "<csharp>" to "<syntaxhighlight lang="csharp" line="1" >")
Line 74: Line 74:
 
  Graphics for Mobile Game is 30 fps and 480 x 800.
 
  Graphics for Mobile Game is 30 fps and 480 x 800.
  
<csharp>
+
<syntaxhighlight lang="csharp" line="1" >
 
     // Frame rate is 30 fps by default for Windows Phone.   
 
     // Frame rate is 30 fps by default for Windows Phone.   
 
     TargetElapsedTime = TimeSpan.FromTicks(333333);   
 
     TargetElapsedTime = TimeSpan.FromTicks(333333);   

Revision as of 18:28, 25 January 2016

Fonts

free game fonts XNA Redistributable Font Pack

Fun with Fonts in XNA

note this font pack is now included in XNA 4

SVN Checkout

All of the examples for this class and the basic game library we wil be building is in our SVN repo this week we'll practice checking out a folder from the repo.


Tools

New Repo for Spring 2013

root

https://iam.colum.edu:8443/svn/GPMonogame3/trunk

Just the Jeff folder

https://iam.colum.edu:8443/svn/GPMonogame3/trunk/jeff


Demos Projects

https://iam.colum.edu:8443/svn/GPMonogame3/trunk/jeff


tortoisesvn http://tortoisesvn.tigris.org/

ankhsvn http://ankhsvn.open.collab.net/

SNV checkout demo.

In the coming weeks we'll learn how to commit to the SNV. Until then all you need to know is how to checkout.

in class

Spritefont demo

IntroFonts/Game1.cs IntroFonts.zip

XNA Structures

Game Class

The XNA Game class has two private properties

  • GraphicsDeviceManager graphics;
  • ContentManager content;
Graphics for windows and xbox are 60 fps. XBOx supports NTSC resolutions (480i, 480p, 720p, 1080i and 1080p 1080p is only on newer hdmi models).
//the game constuctor can be used to set some graphics settings.
graphics.PreferredBackBufferHeight = 768;
graphics.PreferredBackBufferWidth = 1024;
//graphics.PreferredBackBufferHeight = 1080;
//graphics.PreferredBackBufferWidth = 1920;
//graphics.IsFullScreen = true;
Graphics for Mobile Game is 30 fps and 480 x 800.

<syntaxhighlight lang="csharp" line="1" >

   // Frame rate is 30 fps by default for Windows Phone.  
   TargetElapsedTime = TimeSpan.FromTicks(333333);  
 
   // Pre-autoscale settings.  
   graphics.PreferredBackBufferWidth = 480;  
   graphics.PreferredBackBufferHeight = 800;  

</csharp>


  1. Declare SpriteBatch spriteBatch;
  2. Initialize()
  3. LoadContent()
  4. UnloadContent()
  5. Update(GameTime gameTime)

GameTime

FrameRate and GameTime

Time and Timespan

Example of update using GameTime to calculate elapsed time

  • IntroSimpleSpriteUpdateWindows.zip
  • IntroSimpleSpriteWindows/Game1.cs

Understanding GameTime We'll revisit game time when we talk about performance profiling.

  1. Draw(GameTime gameTime)

Console And Trace

We will build a console class later and debug in game.

Texture2D and SpriteBatches

2D Graphics Overview

About textures and Batching

Displays, ViewPorts, Client Bounds


Alpha channels

Demo

SpriteBacth

demo project

  • IntroSimpleSpriteBatchOptionsWindows.zip

spriteBatch.Begin();

IntroSpriteModesDemo.png

  1. Options SpriteBlendMode
  2. Additive Enable additive blending. http://blogs.msdn.com/etayrien/archive/2006/12/19/alpha-blending-part-3.aspx
  3. AlphaBlend Enable alpha blending. http://blogs.msdn.com/etayrien/archive/2006/12/19/alpha-blending-part-2.aspx
  4. None No blending specified.

Other Projects

IntroSimpleSpriteUpdateGravityWindows.zip IntroSimpleSpriteUpdateWindows.zip


Homework

  • XNA Picture With Update
Update your picture to include some movement with the update method. Use the keyboard or mouse to interact with something on the screen
  • Read Chapter 2 in XNA 3.0
  • Read Chapter 4 in XNA 3.0 (yes we skipped 3 we'll come back)

Links