1 / 43

Building Your First Windows Phone Game with XNA

WPH310. Building Your First Windows Phone Game with XNA. Rob Cameron Architect Evangelist Microsoft. Stay to the End to Win!. Free Phone!. Building your First Windows Phone Game with XNA Agenda. Windows Phone 7 as a Game Platform. Free Tools to Build Great Games. The Game Loop.

eugenia
Download Presentation

Building Your First Windows Phone Game with XNA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WPH310 Building Your First Windows Phone Game with XNA Rob Cameron Architect Evangelist Microsoft

  2. Stay to the End to Win! Free Phone!

  3. Building your First Windows Phone Game with XNAAgenda Windows Phone 7 as a Game Platform Free Tools to Build Great Games The Game Loop • Loading Content • Update Event • Draw Event Input on Windows Phone 7 Building a Game with Your Friend AppHub

  4. The Windows Phone Hardware Display Multimedia • 480x800 QVGA • Common detailed specs • Codec acceleration Capacitive touch Memory • 4 or more contact points • 256MB RAM or more • 8GB Flash or more Sensors • A-GPS, Accelerometer, Compass, Gyro GPU Camera • DirectX 9 acceleration • 5 mega pixels or more • Dedicated camera button CPU • ARMv7 Cortex/Scorpion 1G or higher • Qualcomm  MSM7x30, MSM8x55 800Mhz or higher Hardware buttons • Start, Search, Back

  5. Windows Phone 7 as a Game Platform Consistent hardware across OEMs Performance is impressive, especially in 3D Xbox Live is a key platform feature Great tooling to facilitate game development

  6. XNA Game Studio 4.0 Develop games for Windows Phone Enhanced audio support Simplified graphics API’s Visual Studio 2010 integration New configurable effects

  7. Game Loop Overview All games do three things Typical Game Loop • Load content when they start • Update the game world as quickly as possible • Draw the game world as quickly as possible Initialize Engine Get User Input Load Resources Calculate Each of these behaviors maps to a method in the game class created by Visual Studio at the time the XNA game project is created Test Criteria Free Resources Give FeedBack

  8. XNA Framework Game Loop Overview All games do three things XNA Framework Game Loop • Load content when they start • Update the game world as quickly as possible • Draw the game world as quickly as possible Initialize() Updatet() LoadContent() XNA Framework provides the game loop framework on Windows Phone 7 Draw() UnLoadContent()

  9. Loading Content Manage assets in Visual Studio Importers for common game data formats Optimize data into binary format for efficient loading Fully extensible Compile time checking Content projects external in XNA Game Studio 4.0

  10. LoadContent Method • protected override voidLoadContent() • { • // Create a new SpriteBatch, which can be used to draw textures. • spriteBatch = newSpriteBatch(GraphicsDevice); • // TODO: use this.Content to load your game content here • backgroundTexture = Content.Load<Texture2D>("Sprites\\background"); • }

  11. Update and Draw Methods Update() Method – Determines State • Handle input • Calculate movement • Determine collisions • Update animations and effects • Draw() Method – Renders Scene • Loop through objects and draw

  12. Update and Draw Methods • protected override voidUpdate(GameTimegameTime) • { • // Allows the game to exit • if(GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) • this.Exit(); • // TODO: Add your update logic here • base.Update(gameTime); • } • protected override void Draw(GameTimegameTime) • { • GraphicsDevice.Clear(Color.CornflowerBlue); • // TODO: Add your drawing code here • base.Draw(gameTime); • }

  13. Game Development Process Drawing Sprites Moving Sprites Create a Game Object Handling Input

  14. Drawing Sprites and Textures Sprites – images you move around Textures – background images, skin other objects Texture2D represents an image Instantiate Texture2D objects in LoadContent method

  15. Drawing Sprites and Textures • protected override void Draw(GameTimegameTime) • { • GraphicsDevice.Clear(Color.CornflowerBlue); • spriteBatch.Begin(); • spriteBatch.Draw(backgroundTexture, viewportRect, Color.White); • foreach (GameObject enemy in enemies) • { • if (enemy.Alive) • { • spriteBatch.Draw(enemy.Sprite, enemy.Position, enemy.TintColor); • } • } • spriteBatch.End(); • base.Draw(gameTime); • }

  16. Moving Sprites 2D games are a great way to start game development Cartesian coordinate system Track position, direction, and speed for each object

  17. Moving Objects Vectors represent position and speed Position Vector (10,10) – location on screen Velocity Vector (0,10) – direction and speed

  18. Moving Objects Vectors represent position and speed • positionVector+=velocityVector Changing length of velocity vector changes speed

  19. XNA Framework Basics Demo

  20. Game Object Game objects make game development manageable • Encapsulation • Inheritance • All that good OO stuff • Implements mini game loop • Load content • Update • Draw

  21. Working with Game Objects • public override void Update(GameTimegameTime) • { • CheckForCollisions(); • heroShip.Update(gameTime); • statusBoard.Update(gameTime); • for (int i = 0; i < maxEnemies; i++) • { • enemies[i].Update(gameTime); • } • base.Update(gameTime); • }

  22. Working with Game Objects Demo

  23. Handling Input – Touch Can capture up to four touch locations • Declare a TouchCollection • TouchPanel.GetSate() to return a TouchCollection in Update() • Each TouchLocation has state • TouchLocationState.Invalid, Moved, Pressed, Released • A single user touch results in two TouchLocation items • One for Pressed, and one for Released

  24. Handle Input – Accelerometer The Accelerometer can measure acceleration in X, Y, and Z Values for each axis are in the same range • -1 to +1 in each axis A value of 1 means 1G • G is the acceleration due to gravity

  25. Handling Input Demo

  26. AppHub is Your Game Development Partner Full game examples in 2D and 3D Screen management sample Sprite Sheet sample Particle system sample Many other samples for specific game dev tasks http://create.msdn.com

  27. Integrating App Hub Samples Demo

  28. Takeaways Game Development is fun! XNA Game Studio provides a powerful development tool App Hub provides many great samples to get you started

  29. Questions? And pleasefill out your evaluation form! Q&A

  30. Required Slide Speakers, please list the Breakout Sessions, Interactive Discussions, Labs, Demo Stations and Certification Exam that relate to your session. Also indicate when they can find you staffing in the TLC. Related Content • WPH371-HOL | Game Development with Microsoft XNA Framework • WPH374-HOL | Tombstoning, Launcher and Chooser, and More, with Microsoft XNA Framework • WPH304 | New Windows Phone Data Access Features • WPH307 | Connecting Windows Phones and Slates to Windows Azure • WPH311 | Lessons Learned about Application Performance on Windows Phone • Windows Phone Booth after this session

  31. Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Track Resources • AppHub – http://create.msdn.com • Resource 2 • Design Resources for WP7 • Resource 3 • Windows Phone 7 Development Documentation • Resource 4 • Windows Phone 7 Training Kit

  32. Required Slide Speakers, please list the Breakout Sessions, Interactive Discussions, Labs, Demo Stations and Certification Exam that relate to your session. Also indicate when they can find you staffing in the TLC. Windows Phone Related Content Monday, May 16 WPH201: Windows Phone: What’s New? WPH371-INT: Building a Mobile Message Queue for Windows Phone WPH312: What’s New for Windows Phone Development with Microsoft Silverlight? WPH302: Windows Phone Productivity Scenarios with Microsoft Exchange Server 2010 and Microsoft Office 365 WPH373: Meet the Windows Phone Application Platform Engineering Team

  33. Windows Phone Related Content Tuesday, May 17 WPH308: Multi-tasking and Application Switching for Windows Phone OSP312: Developing Microsoft Office Business Solutions that Span the PC, Windows Phone, and the Web WPH309: Enhanced Push Notifications and Live Tiles for Windows Phone WPH303: Understanding the Windows Phone Development Tools COS315: Building Windows Phone Applications with the Windows Azure Platform

  34. Windows Phone Related Content Tuesday, May 17 WPH305: Internet Explorer 9 on Windows Phone OSP209 Building Your First Windows Phone Application for Microsoft SharePoint 2010 WPH203: Understanding Windows Phone Marketplace WPH375-INT: Building Multi-tasking Enabled Windows Phone Applications

  35. Windows Phone Related Content Wednesday, May 18 WPH202: Windows Phone at Microsoft DEV317: Using Microsoft Visual Basic to Build Windows Phone Applications WPH310: Building Your First Windows Phone Game with XNA WPH374-INT: Hardcore Windows Phone Development Questions DEV205: Microsoft Expression for Developers: Demystifying User Interface Design WPH306: Building Windows Phone Applications with Microsoft Silverlight and XNA WPH304: New Windows Phone Data Access Features

  36. Windows Phone Related Content Thursday, May 19 WPH301: Deploying Windows Phone in the Enterprise DPR303: Developing Enterprise-Grade Mobile Solutions WPH307: Connecting Windows Phones and Slates to Windows Azure WPH372-INT: Windows Phone Marketplace: Interactive WPH311: Lessons Learned about Application Performance on Windows Phone WPH311: Lessons Learned about Application Performance on Windows Phone SIM323: User Identity and Authentication for Desktop and Phone Applications

  37. WindowsPhone ResourcesQuestions? Demos? The latest phones? Visit the Windows Phone Technical Learning Center for demos and more… • Business IT resources blogs.technet.com/b/windows_phone_4_it_pros Developer resources craete.msdn.com Experience Windows Phone 7 on-line and get a backstage pass www.windowsphone.com

  38. Win a Windows Phone Contest • SESSION CONTEST* • HAT CONTEST* QUESTIONS? Go to theWPC Information Counter at the TLC How do you enter? • During each Windows Phone session the moderator will post a question;the first person to correctly answer the question and is called on by the moderator will potentially win Enter by visiting the Windows Phone booth, accepting a free Windows Phone branded hat, and wearing that hat during the Event • How am I selected? * Restrictions apply please see contest rules for eligibility and restrictions. Contest rules are displayed in the Technical Learning Center at the WPH info counter • Each day of the event, a Windows Phone representative will randomly select up to 5 people who are observed wearing their Windows Phone branded hat

  39. Resources • Connect. Share. Discuss. http://northamerica.msteched.com Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet • http://microsoft.com/msdn

  40. Complete an evaluation on CommNet and enter to win!

  41. © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related