ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
XNA Game Studio 2.0
Game Programming Made Easy(ier)
Reuben Ahmed
[February 12, 2008]
About Me
? 7 years of .NET/C#
? Minimal game programming
experience
? Avid video game player
¨C *Not reflected in my XBOX Live gamer score
? rahmed@bennettadelson.com
WARNING
? Disclaimer: Code shown during
this presentation is not meant to
be the ¡°right¡± or ¡°best¡± way of
creating a game.
? Purpose: Give you a basic
toolset to start off with XNA.
Agenda
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment (!)
? Distribution model
? Q & A
What is XNA?
? X-Platform Next Generation Architecture
? C# Game Framework
¨C Windows/XBOX 360
¨C Reduced learning curve
¨C Compiles to .NET Compact Framework
¨C Available, Approachable, and nearly Free
? Sony Playstation 3 Dev. Kit = ~$10,500
? XNA is free on Windows.
? $49/4 months or $99/year on XBOX 360.
System Requirements
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
System Requirements
? Visual C# 2005 Express Edition, Standard Edition,
Professional Edition , Team Edition for Software
Architects, Team Edition for Software Developers, Team
Edition for Software Testers, Team Edition for Database
Professionals , Team Suite
? No Visual Studio 2008 support currently!
? DirectX 9.0c, Pixel Shader 1.1+
XNA Studio 2.0 and C# Express URL:
? http://creators.xna.com/Education/newtoxna.aspx
Out of the box architecture
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
Out of the box architecture
? Graphics Device Manager
¨C Automatically sets up interaction with your
graphics card
? Optimized Game Loop
¨C Update, Draw methods
? Content Pipeline
¨C Game Assets (Graphics, Audio, etc.)
? DEMO: Our First XNA Game!
¨C Change background color
Graphics/Textures
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
Graphics/Textures ¨C Drawing
1) Add Asset to your project
¨C Drag and drop graphic
2) Load Graphic into variable
¨C Texture2D class
¨C Content Pipeline method
? Content.Load <Texture2D> (¡°AssetName¡±);
3) Draw it
¨C SpriteBatch class
? SpriteBatch.Draw (Texture2D, Position, Color);
? DEMO: Adding a spaceship graphic!
? DEMO: Tint graphic with Draw
parameter.
Graphics/Textures - Demo
? Vector2 class
¨C Holds X and Y position
¨C Can represent Position, Acceleration, Velocity
Graphics ¨C 2D Coordinates
? GraphicsDevice.Viewport
¨C Window size properties
? DEMO: Centering graphic with Vector2!
? Tip: Texture is drawn with upper left as
starting point¡­
GraphicsGraphics ¨C Window Size
? DEMO: Scale image with Rectangles.
? Tip: Draw order matters!
GraphicsGraphics ¨C Scale
Input
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
? Keyboard
¨C Static class
? Current state of keyboard
? Which keys are pressed
? Keys
¨C Enumerator
¨C Represents almost any key!
? DEMO: Read input to exit game.
Input ¨C Read Keys
? Vector2
¨C (X,Y) can also represent velocity
? Vectors can be added/subtracted¡­
? Vector of (0,0) position + Vector of (5, 2)
velocity = new position of (5, 2).
Input ¨C Vector2 Velocity
? DEMO: Move ship to right.
? DEMO: Use Keyboard to move ship
left/right.
Input ¨C Vector2 Velocity
Collision Detection
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
? My ship is going off the screen!
? First level of collision detection:
¨C Window boundaries
¨C MathHelper class to the rescue¡­
? Clamp() method.
? DEMO: MathHelper.Clamp() to
boundaries.
Collision Detection
? Let¡¯s add an ¡°enemy¡±¡­remember:
¨C Texture2D
¨C Vector2 (position)
¨C Vector2 (velocity)
¨C MathHelper.Clamp (Window Boundaries)
? DEMO: Add a non-hostile Alien that
eerily resembles a Space Invader?!
Collision Detection
? Can we shoot a bullet?
¨C Bullet spawns from spaceship position.
¨C Moves vertically up (negative Y direction)
? DEMO: Kill it, KILL IT!
Collision Detection
? My bullets are too weak!
¨C Rectangles encompass every Texture.
¨C Rectangle.Intersects will help!
? DEMO: Encompass the alien and bullet
in rectangles, and figure out if they
collided¡­
Collision Detection
? 2D Per-Pixel Collision
¨C More expensive, but accurate
? Color Key Collision
¨C Detects collision based on color map!
Collision Detection, etc.
Text Writing
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
Text Writing
? SpriteFont asset
? SpriteBatch.DrawString()
? DEMO: Keep a bullet hit count label¡­
Audio
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
Audio
? Microsoft Cross Platform Audio Creation
Tool
¨C Creates a .XAP ¡°Game Asset¡±
¨C .WAV files
? Classes
¨C audioEngine = new AudioEngine ("ContentAudioPROJECTNAME.xgs");
¨C waveBank = new WaveBank (audioEngine, "ContentAudioWave Bank.xwb");
¨C soundBank = new SoundBank (audioEngine, "ContentAudioSound Bank.xsb");
¨C soundBank.PlayCue (¡°CUENAME");
? DEMO: Background music. Loop it.
? Change volume level
? 3D Spatial audio!
Audio, etc.
XBOX 360 Deployment
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
XBOX 360 Deployment
? This costs money!
? Download XNA Creator¡¯s License ($49 or
$99) from the Games Blade.
? Download/Launch XNA Game Studio
Connect (Free) from the Games Blade.
? Generate a key that your PC can use to
connect to your XBOX360¡­this only has
to be done once.
XBOX 360 Deployment
XBOX 360 Deployment
? Launch XGS Device Center on your PC.
? Your console is now connected!
XBOX 360 Deployment
? Either an XBOX 360 Project Type, OR a
Windows XNA Project Type can be
deployed!
? DEMO: Demonstrate ¡°Copy Windows
Project to XBOX360 Project¡±
? Projects stay in sync.
? DEMO: Add GamePad input handling.
Add rumble!
XBOX 360 Deployment
? DEMO: ¡­Deploy this thing.
¨C Incremental deployment support!
¨C No wireless deployment.
¨C Your game is now available on the Games
Blade!
? DEMO: Debugging on XBOX 360¡­
XBOX 360 Deployment
Distribution Model
? What is XNA?
? System Requirements
? Out of the box functionality
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A
Distribution Model
? XBL currently a managed portfolio
? Game Developer¡¯s Conference 2008
¨C Microsoft prepared to announce XBL
Community Blade for XNA.
Distribution Model
Tip of the iceberg¡­
? Plethora of XNA Tutorials/Starter Kits
? Network Architecture
¨C Client/Server, Peer to Peer, Prediction Code
¨C XBOX Live Profile information
? Artificial Intelligence
¨C State Management samples
? Speech Recognition/Synthesis
¨C System.Speech .NET 3.0
Tip of the iceberg¡­
? XNA Racing Game: YouTube
? 1 week of code (professional game
development company)
? Jitted on the fly, 1080p, 30 FPS, running
on C# (Managed code!), with 2X Anti
aliasing!
? Graphics power is equated to a $350 PC
video card. Anti aliasing¡­one line of
code via XNA.
References
? MSDN XNA Game Studio 2.0
¨C Overview of framework
? http://creators.xna.com/
¨C Active community site
? http://www.xnadevelopment.com/
¨C Beginner tutorials
? http://www.phstudios.com/
¨C Intro?advanced tutorials
Q & A
? What is XNA?
? System Requirements
? Out of the box architecture
? Graphics/Textures
? Input
? Collision Detection
? Text Writing
? Audio
? XBOX 360 Deployment
? Distribution model
? Q & A

More Related Content

Similar to XNAPresentation (20)

PDF
Creating Video Games From Scratch Sky Con
Martha Rotter
?
PPTX
Overview
boybuon205
?
PPTX
Writing Games in .NET with XNA Game Studio
Tim Thomas
?
PPTX
Beginning Game Development in XNA
guest9e9355e
?
PPTX
Beginning Game Development in XNA
guest9e9355e
?
PPT
Game Development and Microsoft XNA (part II)
Charles Bihis
?
PDF
XNA L01¨CIntroduction
Mohammad Shaker
?
PPTX
Deakin
Nick Hodge
?
PDF
Game UI Development_1
Felipe Ramos
?
PPTX
introduction to Xna
Mostafa Zaghloul
?
PPTX
WP7 HUB_XNA overview
MICTT Palma
?
PPT
Pixel-Lab / Games:EDU / Chris Satchell / XNA and Academia
pixellab
?
PPTX
Xna and mono game
Josh Naylor
?
PPTX
Xna and mono game
John van Rij
?
PPTX
Intro to Indie Game Development
Shahed Chowdhuri
?
PPTX
98 374 Lesson 05-slides
Tracie King
?
PPTX
Galactic Wars XNA Game
Sohil Gupta
?
PDF
Multyplatform and mono part 2 - Matteo Nicolotti
Codemotion
?
Creating Video Games From Scratch Sky Con
Martha Rotter
?
Overview
boybuon205
?
Writing Games in .NET with XNA Game Studio
Tim Thomas
?
Beginning Game Development in XNA
guest9e9355e
?
Beginning Game Development in XNA
guest9e9355e
?
Game Development and Microsoft XNA (part II)
Charles Bihis
?
XNA L01¨CIntroduction
Mohammad Shaker
?
Deakin
Nick Hodge
?
Game UI Development_1
Felipe Ramos
?
introduction to Xna
Mostafa Zaghloul
?
WP7 HUB_XNA overview
MICTT Palma
?
Pixel-Lab / Games:EDU / Chris Satchell / XNA and Academia
pixellab
?
Xna and mono game
Josh Naylor
?
Xna and mono game
John van Rij
?
Intro to Indie Game Development
Shahed Chowdhuri
?
98 374 Lesson 05-slides
Tracie King
?
Galactic Wars XNA Game
Sohil Gupta
?
Multyplatform and mono part 2 - Matteo Nicolotti
Codemotion
?

XNAPresentation

  • 1. XNA Game Studio 2.0 Game Programming Made Easy(ier) Reuben Ahmed [February 12, 2008]
  • 2. About Me ? 7 years of .NET/C# ? Minimal game programming experience ? Avid video game player ¨C *Not reflected in my XBOX Live gamer score ? rahmed@bennettadelson.com
  • 3. WARNING ? Disclaimer: Code shown during this presentation is not meant to be the ¡°right¡± or ¡°best¡± way of creating a game. ? Purpose: Give you a basic toolset to start off with XNA.
  • 4. Agenda ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment (!) ? Distribution model ? Q & A
  • 5. What is XNA? ? X-Platform Next Generation Architecture ? C# Game Framework ¨C Windows/XBOX 360 ¨C Reduced learning curve ¨C Compiles to .NET Compact Framework ¨C Available, Approachable, and nearly Free ? Sony Playstation 3 Dev. Kit = ~$10,500 ? XNA is free on Windows. ? $49/4 months or $99/year on XBOX 360.
  • 6. System Requirements ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 7. System Requirements ? Visual C# 2005 Express Edition, Standard Edition, Professional Edition , Team Edition for Software Architects, Team Edition for Software Developers, Team Edition for Software Testers, Team Edition for Database Professionals , Team Suite ? No Visual Studio 2008 support currently! ? DirectX 9.0c, Pixel Shader 1.1+ XNA Studio 2.0 and C# Express URL: ? http://creators.xna.com/Education/newtoxna.aspx
  • 8. Out of the box architecture ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 9. Out of the box architecture ? Graphics Device Manager ¨C Automatically sets up interaction with your graphics card ? Optimized Game Loop ¨C Update, Draw methods ? Content Pipeline ¨C Game Assets (Graphics, Audio, etc.) ? DEMO: Our First XNA Game! ¨C Change background color
  • 10. Graphics/Textures ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 11. Graphics/Textures ¨C Drawing 1) Add Asset to your project ¨C Drag and drop graphic 2) Load Graphic into variable ¨C Texture2D class ¨C Content Pipeline method ? Content.Load <Texture2D> (¡°AssetName¡±); 3) Draw it ¨C SpriteBatch class ? SpriteBatch.Draw (Texture2D, Position, Color);
  • 12. ? DEMO: Adding a spaceship graphic! ? DEMO: Tint graphic with Draw parameter. Graphics/Textures - Demo
  • 13. ? Vector2 class ¨C Holds X and Y position ¨C Can represent Position, Acceleration, Velocity Graphics ¨C 2D Coordinates
  • 14. ? GraphicsDevice.Viewport ¨C Window size properties ? DEMO: Centering graphic with Vector2! ? Tip: Texture is drawn with upper left as starting point¡­ GraphicsGraphics ¨C Window Size
  • 15. ? DEMO: Scale image with Rectangles. ? Tip: Draw order matters! GraphicsGraphics ¨C Scale
  • 16. Input ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 17. ? Keyboard ¨C Static class ? Current state of keyboard ? Which keys are pressed ? Keys ¨C Enumerator ¨C Represents almost any key! ? DEMO: Read input to exit game. Input ¨C Read Keys
  • 18. ? Vector2 ¨C (X,Y) can also represent velocity ? Vectors can be added/subtracted¡­ ? Vector of (0,0) position + Vector of (5, 2) velocity = new position of (5, 2). Input ¨C Vector2 Velocity
  • 19. ? DEMO: Move ship to right. ? DEMO: Use Keyboard to move ship left/right. Input ¨C Vector2 Velocity
  • 20. Collision Detection ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 21. ? My ship is going off the screen! ? First level of collision detection: ¨C Window boundaries ¨C MathHelper class to the rescue¡­ ? Clamp() method. ? DEMO: MathHelper.Clamp() to boundaries. Collision Detection
  • 22. ? Let¡¯s add an ¡°enemy¡±¡­remember: ¨C Texture2D ¨C Vector2 (position) ¨C Vector2 (velocity) ¨C MathHelper.Clamp (Window Boundaries) ? DEMO: Add a non-hostile Alien that eerily resembles a Space Invader?! Collision Detection
  • 23. ? Can we shoot a bullet? ¨C Bullet spawns from spaceship position. ¨C Moves vertically up (negative Y direction) ? DEMO: Kill it, KILL IT! Collision Detection
  • 24. ? My bullets are too weak! ¨C Rectangles encompass every Texture. ¨C Rectangle.Intersects will help! ? DEMO: Encompass the alien and bullet in rectangles, and figure out if they collided¡­ Collision Detection
  • 25. ? 2D Per-Pixel Collision ¨C More expensive, but accurate ? Color Key Collision ¨C Detects collision based on color map! Collision Detection, etc.
  • 26. Text Writing ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 27. Text Writing ? SpriteFont asset ? SpriteBatch.DrawString() ? DEMO: Keep a bullet hit count label¡­
  • 28. Audio ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 29. Audio ? Microsoft Cross Platform Audio Creation Tool ¨C Creates a .XAP ¡°Game Asset¡± ¨C .WAV files ? Classes ¨C audioEngine = new AudioEngine ("ContentAudioPROJECTNAME.xgs"); ¨C waveBank = new WaveBank (audioEngine, "ContentAudioWave Bank.xwb"); ¨C soundBank = new SoundBank (audioEngine, "ContentAudioSound Bank.xsb"); ¨C soundBank.PlayCue (¡°CUENAME"); ? DEMO: Background music. Loop it.
  • 30. ? Change volume level ? 3D Spatial audio! Audio, etc.
  • 31. XBOX 360 Deployment ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 32. XBOX 360 Deployment ? This costs money! ? Download XNA Creator¡¯s License ($49 or $99) from the Games Blade. ? Download/Launch XNA Game Studio Connect (Free) from the Games Blade. ? Generate a key that your PC can use to connect to your XBOX360¡­this only has to be done once.
  • 34. XBOX 360 Deployment ? Launch XGS Device Center on your PC.
  • 35. ? Your console is now connected! XBOX 360 Deployment
  • 36. ? Either an XBOX 360 Project Type, OR a Windows XNA Project Type can be deployed! ? DEMO: Demonstrate ¡°Copy Windows Project to XBOX360 Project¡± ? Projects stay in sync. ? DEMO: Add GamePad input handling. Add rumble! XBOX 360 Deployment
  • 37. ? DEMO: ¡­Deploy this thing. ¨C Incremental deployment support! ¨C No wireless deployment. ¨C Your game is now available on the Games Blade! ? DEMO: Debugging on XBOX 360¡­ XBOX 360 Deployment
  • 38. Distribution Model ? What is XNA? ? System Requirements ? Out of the box functionality ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A
  • 40. ? XBL currently a managed portfolio ? Game Developer¡¯s Conference 2008 ¨C Microsoft prepared to announce XBL Community Blade for XNA. Distribution Model
  • 41. Tip of the iceberg¡­ ? Plethora of XNA Tutorials/Starter Kits ? Network Architecture ¨C Client/Server, Peer to Peer, Prediction Code ¨C XBOX Live Profile information ? Artificial Intelligence ¨C State Management samples ? Speech Recognition/Synthesis ¨C System.Speech .NET 3.0
  • 42. Tip of the iceberg¡­ ? XNA Racing Game: YouTube ? 1 week of code (professional game development company) ? Jitted on the fly, 1080p, 30 FPS, running on C# (Managed code!), with 2X Anti aliasing! ? Graphics power is equated to a $350 PC video card. Anti aliasing¡­one line of code via XNA.
  • 43. References ? MSDN XNA Game Studio 2.0 ¨C Overview of framework ? http://creators.xna.com/ ¨C Active community site ? http://www.xnadevelopment.com/ ¨C Beginner tutorials ? http://www.phstudios.com/ ¨C Intro?advanced tutorials
  • 44. Q & A ? What is XNA? ? System Requirements ? Out of the box architecture ? Graphics/Textures ? Input ? Collision Detection ? Text Writing ? Audio ? XBOX 360 Deployment ? Distribution model ? Q & A

Editor's Notes

  • #46: Who owns or has played an XBOX 360? Who has done any directX/openGL or graphics development? Performance characteristics of an XBOX 1 can be done XBOX Symbol for development: ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.XNAGS.1033/XNA/UsingXNA_XboxProgramming.htm Dream Build Play (2008) http://www.dreambuildplay.com/main/default.aspx Prizes: An invitation to show your entry at GDC 2008. An interview for an internship at Microsoft Research, Lionhead Studios or Rare Ltd in the UK.