XNA Intro Workshop

4,559 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,559
On SlideShare
0
From Embeds
0
Number of Embeds
56
Actions
Shares
0
Downloads
106
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

XNA Intro Workshop

  1. 1. Microsoft’s XNA Sjors Miltenburg Software Ontwikkelaar smiltenburg@sogyo.nl www.software-innovators.nl
  2. 2. Who?
  3. 3. Who?
  4. 4. First video game, 1958
  5. 5. First video game, 1958
  6. 6. Spacewar, 1962
  7. 7. The Galaxy Game, 1971
  8. 8. Pong, 1972
  9. 9. Spaceinvader, 1978
  10. 10. Commodore, 1982
  11. 11. Super Mario Bros, 1985
  12. 12. Wolfenstein 3D, 1992
  13. 13. Duke Nukem 3D, 1996
  14. 14. Call of Duty 4, 2007
  15. 15. Facts USA [2007] $ 17.9 billion NL game industry bigger than film industry
  16. 16. Microsoft & gaming
  17. 17. XNA • tools for game development • Completely managed environment • All aspects of game production in one system • Game development is accessible
  18. 18. XNA Platform • XNA Framework • XNA Build • XNA Framework Content Pipeline • XNA Game Studio
  19. 19. What do you need? .NET 3.0 • Visual Studio (C# Express is free!) • XNA Framework • XNA Game Studio •
  20. 20. XNA Framework • Microsoft .NET CLR 3.0 (3.5?) • Cross-Platform Game Development – Windows XP – Windows Vista – Xbox 360  – Zune
  21. 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. 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. 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. 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…
  25. 25. Components • Example of a Component – Virtual keyboard voor de XBOX 360
  26. 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. 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. 28. Application Model Game Class, starting point • Game – Initialize – LoadContent – Update – Draw – UnloadContent • GameComponent, DrawableGameComponent
  29. 29. Content Pipeline extensible content processing framework • 2D File Formats (.DDS, .BMP, .JPG, .PNG, .TGA) • 3D File Formats (.FBX, .X) • Material File Formats (.FX) • Audio File Formats (.XAP) •
  30. 30. 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
  31. 31. Core Framework • Graphics – SpriteBatch, BasicEffect, Texture2d, GraphicsDevice, Model, VertexBuffer • Audio – SoundBank, WaveBank, Cue, AudioEngine – Looping, Streaming en memory management – low-level buffer management • Input – GamePad, Keyboard, Mouse
  32. 32. Core Framework • Math – MathHelper.ToRadians(float angle), PiOver4 • Storage – Title Storage (Shaders, Meshes, Textures, Sounds…) – User Storage (Save games, Scores…) – Emulated on the Windows Platform • Network – NetworkSession, PacketReader, NetworkGamer
  33. 33. XNA Framework Overzicht 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
  34. 34. Platform abstraction • Don’t worry about the platform, but about your game! • Mono started an implementation
  35. 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. 36. Community • 3D Models – Cars, Houses, humans, levels • Mostly free • http://turbosquid.com/xna
  37. 37. Community • Example of a community built Component – XNA Console
  38. 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)
  39. 39. Getting creative • Creating games with XNA is easy!
  40. 40. We will be building • Tank game – Drive, aim and shoot
  41. 41. Steps Run an empty game • Load graphical content • Show tank on screen • Handle user input • – Rotate – Move – Shoot
  42. 42. Step 1: Empty game • Create a new XNA game • Run!
  43. 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. 44. Step 3.1: Display content • Draw tank • Draw turret • Draw @ center of the screen • Does it matter what you draw first?
  45. 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. 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. 47. Step 5: Shoot • CannonBall Class • One shot at a time (space invader style)
  48. 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. 49. Step 7: Network code • Sample code – Search for “XNA Network Prediction” – Uses Microsoft Live • Create a local account
  50. 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 •
  51. 51. Vragen?
  52. 52. Nintendo’s Wii!
  53. 53. Wiimote Knoppen • Accelerometer • IR-camera • Buzzer • Leds • Bluetooth •
  54. 54. Accelerometer • ADXL330 3-Axis ±3g iMEMS® Accelerometer
  55. 55. Accelerometer Y (-3G,3G) Z (-3G, 3G)
  56. 56. Accelerometer 0 Stil 0 1
  57. 57. Accelerometer 0 Omhoog 0 >1
  58. 58. Accelerometer 0 Omlaag 0 <1
  59. 59. IR-camera • PixArt optical sensor Multi-Object Tracking engine (MOT sensor™) • Sensor bar
  60. 60. IR-camera
  61. 61. Bluetooth • BCM2042 Advanced Wireless Keyboard/Mouse Bluetooth® Chip • HID Device
  62. 62. Wiimote -> PC • OS • Bluetooth Device • Bluetooth stack
  63. 63. API’s wiimote-api RMX Automation GlovePIE WiimoteLib WiinRemote libwiimote WMD Wiiewer WiimoteCPP WiiYourself! Wiimotecomm
  64. 64. WiimoteLib classes
  65. 65. Simplicity
  66. 66. Demo time! • Flying with the Wii

×