Windows phone 7 xna


Published on

Published in: Technology, Design
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Windows phone 7 xna

  1. 1. Glen Gordon<br />Developer Evangelist<br /><br />@glengordon<br />Developing WP7 Games using XNA<br />
  2. 2. Agenda<br />2<br />Windows Phone 7 – A new beginning<br />XNA Game Studio 4.0 – Powerful, Productive, Portable<br />XNA Framework<br />- Game Loop, Graphics, Audio, Media, Touch, Sensors<br />XBOX Live <br />Q & A<br />
  3. 3. Games Hub Featuring Xbox LIVE<br />3<br />
  4. 4. Xbox LIVE is Gaming Services<br />Gamertag<br />Friends<br />Achievements<br />Windows Phone will extend the Xbox LIVE brand beyond the console for the first time<br />MerchandisingPremiumPlacement<br />Windows Phone is the first step towards our vision of a ubiquitous gaming service<br />Differentiates your title from the rest<br />
  5. 5. Game Development Opportunities<br />To use the great features of Xbox LIVE<br />Without Xbox LIVE You can still write<br />andpublish games for <br />Windows Phone<br />Find a publisher!<br />Lots to choose from!<br />We’re interested in your great games!<br />Create great games for marketplace<br /><br />
  6. 6. Windows Phone 7 Hardware<br />Consistent sets of hardware capabilities defined by Microsoft<br />Resolution<br />Touch Input<br />CPU / GPU<br />RAM<br />Hardware keyboard is optional<br />
  7. 7. User Experience Frameworks<br />Modern XAML/event-driven application UI framework<br />Rapid creation of visually rich apps<br />HTML/Javascript<br />Mature, robust, widely deployed technology<br />High performance game framework<br />Rapid creation of multi-screen 2D and 3D games <br />Rich content pipeline<br />Mature, robust, widely adopted technology spanning Xbox, Windows, and Zune<br />GAMES(and applications)<br />APPLICATIONS<br />(and games)<br />
  8. 8. Powerful<br />Productive<br />Portable<br />
  9. 9. XNA Game Studio<br />Makes game development easier<br />XNA Framework provides robust APIs for games<br />C#, .NET and Visual Studio tooling<br />Solutions for game content processing<br />Not an engine solution<br />CreatingGames<br />
  10. 10. XNA Game Studio 4.0<br />Enhanced audio support<br />Develop for Windows Phone 7<br />Simplified graphics APIs<br />Visual Studio 2010 integration<br />New configurable effects<br />
  11. 11. Powerful<br />
  12. 12. Managed Code for Game Development<br />Windows Phone 7 <br /> Uses the .NET platform<br />Managed code platform, no unsafe code<br />.NET/XNA is used for games today!<br />XNA Game Studio 4.0 is C# exclusive<br />800+ managed code games on XBLA/XBLIG<br /><br />Windows games published through portals<br />
  13. 13. Addressing Performance Head-on<br />Frameworks designed for performance<br />Frameworks designed for performance<br />Frameworks designed for performance<br />Frameworks designed for performance<br />XNA Framework designed for gaming scenarios<br />Commitment to future of managed code <br />No unnecessary garbage generation<br />Three + years of profiling and investment <br />We’ve built for performance on Windows Phone 7<br />Math libraries optimized <br />Efficient APIs with tuned transitions to native code<br />
  14. 14.<br />
  15. 15. Productive<br />
  16. 16. Visual Studio and .NET<br />Productive development with .NET and C#<br />High performance IDE<br />Intellisense makes coding faster<br />Integrated build/deploy/debug experience<br />MSBuild engine for build automation<br />
  17. 17. Content Pipeline<br />17<br />Simplify Your Content Usage!<br />Manage assets in Visual Studio<br />Importers for common game data formats<br />Optimize data into binary format for efficient loading<br />Fully extensible<br />Content projects external in XNA Game Studio 4.0<br />
  18. 18. Simplifying Game Development<br />XNA Framework<br />18<br />
  19. 19. Bridging the Gap<br />The XNA Framework Game Loop is layered on top of the Silverlight Application object on Windows Phone 7<br />Provides the bulk of integration of API’s<br />Most of the XNA Framework can be accessed from Silverlight applications<br />Including Gamer Services (Xbox LIVE)<br />In this release some sharing/composition is not complete<br />Scenes using GraphicsDevice from XNA Framework and UIElements from Silverlight<br />You’ll want to choose the technology that works best for your scenarios<br />
  20. 20. Choosing the Right Technology<br />Graphics<br />UI control heavy consider Silverlight<br />Desire vector graphics in XAML <br />Media<br />Rich video support in application<br />Tooling<br />If you use Microsoft Blend in your pipeline<br />
  21. 21. Leveraging the Right Technology<br />Graphics<br />Using 3D graphics<br />Sprite heavy 2D applications should consider the XNA Framework Game Loop <br />Simulation/Drawing<br />Those who prefer a traditional update/draw/present frame loop<br />Tooling<br />Those who want to use the XNA Framework Content Pipeline graphics types<br />
  22. 22. XNA Framework Game Loop<br />Start simple and customize!<br />XNA Framework Game Loop Example<br />protectedoverridevoid Update(GameTimegameTime)<br />{<br /> // Allows the game to exit<br /> if(GamePad.GetState(PlayerIndex.One).Buttons.Back==<br />ButtonState.Pressed)<br />this.Exit();<br /> // TODO: Add your update logic here<br />base.Update(gameTime);<br />}<br />protectedoverridevoid Draw(GameTimegameTime)<br />{<br />GraphicsDevice.Clear(Color.CornflowerBlue);<br /> // TODO: Add your drawing code here<br />base.Draw(gameTime);<br />}<br />Traditional update/draw/present frame loop<br />Core programming model consistent with previous releases<br />Changes implemented yield better power performance on devices<br />System integration with Windows Phone 7 best practices<br />Translated to existing XNA Framework concepts<br />
  23. 23. Demo:Game Loop<br />
  24. 24. Graphics<br />24<br />
  25. 25. Graphics Overview<br />Evolution of our existing immediate mode rendering API<br />Simplifies for resource and render state management<br />Feature segmentation between “Reach”/“HiDef” profiles<br />Rendering primitives 2D and 3D<br />
  26. 26. Configurable Effects<br />BasicEffect<br />SkinnedEffect<br />New configurable effect classes on all platforms<br />EnvironmentMapEffect<br />DualTextureEffect<br />Custom effects not available on Windows Phone 7<br />AlphaTestEffect<br />
  27. 27. System Support: Scaler and Orientation<br />Write your game without worrying about native resolution or orientation<br />Automatic rotation between portrait and landscapeTouch automatically supports both scale and orientation changes<br />Scaler can drastically improve performance<br />Trade off performance for “crispness” and shade fewer pixels800x480 = 384,000 pixels, 480x320 = 153,600 pixels<br />Upsample an arbitrary back buffer to native device resolution<br />Far higher quality than bilinear filteringAllows for easier porting from other platforms<br />Scaling/Rotation comes for “free” from Hardware<br />
  28. 28. Demo:Effects<br />
  29. 29. Can you hear me now?<br />Audio & Media<br />29<br />
  30. 30. Audio Capture Example<br />Audio<br />publicvoidEventDrivenCapture()<br />{<br />mic= Microphone.Default;<br />buffer = new byte[mic.GetSampleSizeInBytes(mic.BufferDuration)];<br />mic.BufferReady += newEventHandler(OnBufferReady);<br />DynamicPlayback = newDynamicSoundEffectInstance(mic.SampleRate,<br />AudioChannels.Mono);<br />}<br />publicvoidOnBufferReady(object sender, EventArgsargs)<br />{<br />// Get the latest captured audio. <br />int duration = mic.GetData(buffer);<br />// Do some post-capture processing and playback. <br />MakeMeSoundLikeARobot(buffer, duration);<br />DynamicPlayback.SubmitBuffer(buffer);<br />}<br />Audio Capture and Playback<br />Simple API to play back WAV data<br />Modify pitch, volume, pan audio<br />Ability to play synthesized/buffered audio<br />Serialize captured data<br />Provides more control over System.Mediatypes on Windows Phone 7<br />Audio Playback Example<br />// Load a sound effect from a raw stream<br />SoundEffecteffect1 =<br />SoundEffect.FromStream(GetStreamFromTheWeb("http://url.wav"));<br />effect1.Play();<br />// Create dynamic audio on the fly<br />byte[] fluteSound = GetFluteNote();<br />effect2 = newSoundEffect(fluteSound, SampleRate, AudioChannels.Stereo);<br />SoundEffectInstanceinstance = effect2.CreateInstance();<br />instance.Pan = -1; instance.Pitch = 1.5f;<br />instance.Play();<br />Microphone/Bluetooth Support<br />Playback through headset<br />Capture through mic or headset<br />
  31. 31. Media – Music/Photos/Video<br />URI Song Playback Example<br />Music Enumeration and Playback<br />// Constructs a song from a URI<br />UrimediaStreamUri = newUri("http://song.asx");<br />SongstreamedSong = Song.FromUri("Song", mediaStreamUri);<br />// Play the song<br />MediaPlayer.Play(streamedSong);<br />Control and enumerate users’ media within a game<br />Ability to play songs from URI/URL (i.e. music app)<br />Picture Enumeration and Playback<br />Supports photo picking/editing/publishing<br />Retrieve Image Data<br />MediaLibrarymedia =newMediaLibrary();<br />// Get the JPEG image data<br />StreammyJpegImage = ReadAndModifyPicture(somePicture);<br />// Save texture to Media Library   <br />media.SavePicture("Awesome", myJpegImage);<br />Video Playback<br />Uses standard video player API<br />Show/Hide controls<br />
  32. 32. Demo:Sound<br />
  33. 33. Interacting with games gets easier!<br />Input / Touch<br />33<br />
  34. 34. Input Overview<br />Cross Platform Input API<br />Xbox 360 Controllers (Xbox/Windows)<br />Keyboard (Xbox/Windows/Windows Phone 7)<br />Touch Input Handling<br />vartouchCollection= TouchPanel.GetState();<br />//...<br />foreach(vartouchLocationintouchCollection)<br />{<br />if(touchLocation.State == <br />TouchLocationState.Released)<br /> {<br />//...<br /> }<br />}<br />Touch API<br />Available across platforms for portability (fewer #ifdefs) <br />Multipoint on Windows Phone 7 and Windows<br />Orientation and resolution aware<br />Developer can override<br />
  35. 35. For Silverlight and XNA Framework<br />Sensors<br />35<br />
  36. 36. Sensor Overview<br />Leverage Platform Features on Windows Phone 7<br />VibrationExample<br />VibrateControllerrumbler;<br />rumbler.Start(TimeSpan.FromSeconds(2));<br />Location<br />Accelerometer<br />Vibration<br />Accelerometer Example<br />Accelerometer accelerometer = new<br />Accelerometer();<br />accelerometer.ReadingChanged +=AccelerometerReadingChanged;<br />accelerometer.Start();<br />
  37. 37. Demo:Touch<br />
  38. 38. Xbox LIVE<br />38<br />
  39. 39. Connectivity at a Glance<br />Windows Phone 7 OS<br />Xbox LIVE<br />HTTP<br />Push<br />Gamer Services<br />Invites<br />Avatars<br />Profile<br />Achieve-ments<br />Leader-boards<br />TrialMode<br />
  40. 40. Profile<br />Your Identity in the Cloud<br />Your phone knows you by your Windows Live ID<br />Link to your Gamertag<br />
  41. 41. Profile<br />Read a Player’s Profile<br />// Profile access<br />SignedInGamergamer =Gamer.SignedInGamers[0];<br />// Get the player's GamerTag to display<br />string gamerTag = gamer.Gamertag;<br />// A SignedInGamer has a Profile<br />GamerProfileprofile = gamer.GetProfile();<br />// Get the player's current GamerScore<br />intgamerScore = profile.GamerScore;<br />// get the gamer picture (PNG file stream)<br />Stream gamerPictureStream = profile.GamerPicture;<br />
  42. 42. Achievements<br />Award an Achievement<br />// Award an achievement<br />SignedInGamergamer = Gamer.SignedInGamers[0];<br />gamer.AwardAchievement("Attended TechEd 2010");<br />Real achieventments<br />Real gamerscore<br />Up to 20 awards, 200G total<br />Dead simple API, deep game design<br />Read Achievements<br />// Get achievements<br />AchievementCollectionachievements = gamer.GetAchievements();<br />// walk through achievements<br />foreach (Achievement ain achievements)<br />{<br />string name = a.Name;<br />string description = a.Description;<br />boolearned = a.IsEarned;<br />intscore = a.GamerScore;<br />Stream icon = a.Picture; <br />}<br />
  43. 43. Leaderboards<br />Write to a Leaderboard<br />// Create leaderboard identity with game mode 1<br />LeaderboardIdentityid =<br />LeaderboardIdentity.Create(LeaderboardKey.BestScoreLifeTime, 1);<br />// get the leaderboard writer from the signed in gamer<br />LeaderboardWriterwriter = gamer.LeaderboardWriter;<br />// get the leaderboard entry for the identity<br />LeaderboardEntryentry = writer.GetLeaderboard(id);<br />// write new leaderboard data<br />entry.Rating = 1000;<br />entry.columns.SetValue("Outcome",LeaderboardOutcome.Win);<br />Compete withFriends<br />Score- or Time-based<br />Fixed columns<br />10k blob data<br />Pivot on gamer<br />Read From a Leaderboard<br />// Read from leaderboard with page size of 10<br />LeaderboardReaderreader =LeaderboardReader.Read(id, gamer, 10);<br />foreach (LeaderboardEntryein reader.Entries)<br />{<br />// score or time, as defined by identity. Rating determines rank.<br />long rating = e.Rating;<br />// read additional column data<br />long wins = e.Columns.GetValueInt64("Wins");<br />Stream blob = e.Columns.GetValueStream("Blob");<br />}<br />reader.PageDown();<br />
  44. 44. Trial Mode<br />Simple check<br />Simulate for testing<br />Send user to your Marketplace offer<br />Trial Mode<br />Guide.SimulateTrialMode =true;<br />// if we are in trial mode, show a marketplace offering<br />if(Guide.IsTrialMode)<br />{<br />PlayerIndexplayerIndex = Gamer.SignedInGamers[0].PlayerIndex;<br />Guide.ShowMarketplace(playerIndex);<br />}<br />
  45. 45. Avatars<br />Currently supported through web service only<br />Static pose rendered on LIVE back-end<br />Download as a stream<br /><br />
  46. 46. Game Invites<br />Game invites are handled through email<br />Guide.ShowGameInvite() invokes platform picker UI<br />Player chooses game invite recipients<br />Friends see invitations in their games hub<br />
  47. 47. Portable<br />47<br />
  48. 48. Target Three Screens<br />XNA Framework designed to be cross platform<br />Smaller time investment and target more sockets<br />Project synchronization between platforms<br />
  49. 49. XNA Framework Profiles<br />Create a clear development environment<br />Target broadly or platform showcases<br />Designed for compatibility across screens/devices<br />This profile includes Windows Phone 7<br />Reach<br />Platform showcase features<br />Xbox 360/Windows Only<br />HiDef<br />
  50. 50. Demo:Building 2d and 3d games<br />
  51. 51. Summary<br />Powerful<br />Great managed code games, working today<br />Windows Phone provides a powerful platform for gaming<br />Productive<br />Focus on being a game developer<br />Great tools make you more productive<br />Portable<br />Target more platforms easily<br />Focus on your game differences, not the technology<br />
  52. 52. Call to Action<br />Download the Windows Phone Developer Tools<br /> <br />Create awesome games!<br />
  53. 53. Additional Resources<br />Email: <br /><br />On the web:<br />Hundreds of samples<br />Lots of MVPs and experts to help you get started<br />XNA Creators Club @<br />Team Blog @<br />Shawn Hargreaves @ Tech Info!)<br />Contact Microsoft<br />Blogs<br />Peer Support @<br />
  54. 54. Q&A<br />
  55. 55. © 2010 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.<br />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. <br />MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.<br />