17. XNA
• tools for game development
• Completely managed environment
• All aspects of game production in one
system
• Game development is accessible
18. XNA Platform
• XNA Framework
• XNA Build
• XNA Framework Content Pipeline
• XNA Game Studio
19. What do you need?
.NET 3.0
•
Visual Studio (C# Express is free!)
•
XNA Framework
•
XNA Game Studio
•
20. XNA Framework
• Microsoft .NET CLR 3.0 (3.5?)
• Cross-Platform Game Development
– Windows XP
– Windows Vista
– Xbox 360
– Zune
21. XNA Framework overview
Games Code Content Components
Starter Kits
Extended
Application Model Content Pipeline
Framework
Core
Graphics Audio Input Math Storage
Framework
Platform XACT XINPUT XContent
Direct3D
Legend Community
XNA Provides You Provide
22. XNA Framework overview
Games Code Content Components
Starter Kits
Extended
Application Model Content Pipeline
Framework
Core
Graphics Audio Input Math Storage
Framework
Platform XACT XINPUT XContent
Direct3D
Legend Community
XNA Provides You Provide
23. Starter Kits
“Take our games and make them your own”
• “Complete” games
Starting point for your own games
–
Available through “New Project…”
–
Hit F5 and done!
–
Documentation and tutorials
–
24. Components
• They use the standard gameloop
– Initialize, Load, Update, Draw, Unload
Create and re-use functionality
•
Use 3rd party components
•
Community has a standard
•
Menus, virtual keyboard, game engine,
•
game info, radar’s, map, etc…
26. XNA Framework overview
Games Code Content Components
Starter Kits
Extended
Application Model Content Pipeline
Framework
Core
Graphics Audio Input Math Storage
Framework
Platform XACT XINPUT XContent
Direct3D
Legend Community
XNA Provides You Provide
27. Application Model
• Platform abstraction
– Don’t worry about the platform
• First line of code is for your game
• Game class
– Starting point for your game
28. Application Model
Game Class, starting point
• Game
– Initialize
– LoadContent
– Update
– Draw
– UnloadContent
• GameComponent,
DrawableGameComponent
35. XACT
• Microsoft Cross-Platform Audio Creation
Tool
• Create audio files for XNA games
• Compiles .wav files
• Add info to the sound
– Looping, volume levels
36. Community
• 3D Models
– Cars, Houses, humans, levels
• Mostly free
• http://turbosquid.com/xna
38. Deployment to Xbox 360
• What do you need to deploy to Xbox 360?
– Xbox Live Account
– XNA Game Launcher
– Connection to computer
– XNA Creators Club account
• XNA Creators Club account
– 49 euro (4 months)
– 99 euro (1 year)
43. Step 2: Load Content
• Create a Tank Class
– Vector2 (x,y) for position
– Float (Radians) for direction
• 3 resources (tank, turret, canonball)
• Texture2D
– ContentManager.Load<2DTexture>(“Tank”);
44. Step 3.1: Display content
• Draw tank
• Draw turret
• Draw @ center of the screen
• Does it matter what you draw first?
45. Step 3.2: Display content
• SpriteBatch.Begin();
• SpriteBatch.Draw(7 implementations);
• SpriteBatch.End();
• Screen
– GraphicsManager.GraphicsDevice.Viewport
– 0,0 = top left corner
– 800,600 = bottom right corner
46. Step 4: Handle User input
• KeyboardState = Keyboard.GetState();
• If (KeyboardState.isKeyDown(Keys.Up));
• Where do we place this code?
• Rotate (Tank & turret)
• Move
• Vector2 Movement = new Vector2();
• Movement.X += moveDist * (float)Math.Cos(Rotation);
• Movement.Y += moveDist * (float)Math.Sin(Rotation);
47. Step 5: Shoot
• CannonBall Class
• One shot at a time (space invader style)
48. Step 6: Shoot Enemy
• Draw stationary tank
• Hit?
– Rectangle.Intersects
– Advanced: Per pixel collision
– Where should this code go?
• Draw tank health
– Add new SpriteFont to content folder
– Load Content
– SpriteBatch.DrawString();
49. Step 7: Network code
• Sample code
– Search for “XNA Network Prediction”
– Uses Microsoft Live
• Create a local account
50. Resources
http://creators.xna.com/
•
http://blogs.msdn.com/xna
•
http://www.turbosquid.com/xna
•
http://xbox360homebrew.com
•
http://www.riemers.net
•
http://www.xnadevelopment.com
•
Search for XNA at Google with Live Search
•