440 likes | 582 Views
PLAT-750T. Build your first Metro style game. Chas. Boyd Principal Program Manager, Graphics Microsoft Corporation. The Opportunity. $10B in game software per year worldwide 145M active gamers in US alone Over 50% of all current ‘apps’ are games
E N D
PLAT-750T Build your first Metro style game Chas. Boyd Principal Program Manager, Graphics Microsoft Corporation
The Opportunity • $10B in game software per year worldwide • 145M active gamers in US alone • Over 50% of all current ‘apps’ are games • Windows is now spanning an even broader range of devices
Windows 8 has everything you need to write and ship a game to millions of customers
demo MarbleMaze Chas. Boyd Principle Program Manager Windows Graphics
Typical Game Components Your Killer Game Graphics Game Input Cut Scenes Audio Tools Local Services Connected Services Sound FX User ID 3-D Touch Streaming Activation Compilers Sensors Effects Storage Music Distribution Debuggers 2-D, Text Search & Settings … Game Controllers Asset Processors UI Controls Roaming
DirectX is Direct Access to Hardware • Games require smooth interaction -> fast graphics • DirectX gives you control of the low-level hardware
3D Rendering • Direct3D 11 is fully supported in Metro style apps • Choice of the latest AAA games • All Windows 8 systems support Direct3D • The most direct graphics API available in Windows 8 • Separate talk available on Direct3D <751> • Hardware feature levels’ range from DirectX9 to DirectX11 • ‘Session on scaling visual quality across devices <752>
2D Rendering and Text • Many popular games use 2-D rendering • Even 3-D games have “HUD Art”: score, health bar, etc. • Direct2D is the rendering API for 2-D graphics • Drawing vector graphics, bitmaps, image effects, and text • Use DirectWrite for world-ready text layout and formatting • Works seamlessly with Direct3D • All Direct3D samples use Direct2D for HUD elements
Input • Touch • PointerPoint API supports touch, + mouse, and stylus • Sensors • Sensor APIs return data from Gyro, Accelerometer, and Compass • ‘Sensor Fusion’ returns orientation state computed from all three • Game Controllers • XInput API supports Xbox game controllers
Audio • XAudio2 • Optimized for low-latency playback of sound effects • Performs efficient mixing of multiple simultaneous effects • Media Foundation • Simplifies streaming audio such as background music, • Can access songs from music library via a contract
Cut Scenes • Media Foundation • Simplifies streaming video playback • Supports a variety of media formats • Video is integrated with Direct3D11 for optimal performance • See talk on Game Audio and Media <755>
Real-time Game Architecture • Initialization • Allocate resources • Load state, load media assets • Main Loop: • Poll input -local controls and network input • Update state -AI, physics, collisions, animations, etc. • Render -generate the graphics for the new state • Present -present the resulting image on the display • Update Audio
Main App Loop using namespace Windows::ApplicationModel; using namespace Windows::ApplicationModel::Core; auto dispatcher = m_window->Dispatcher; m_window->Activate(); while( true ) // Main app loop { dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); updateAnimatedState(); // update app logic, animations, etc. m_renderer->Render(); // render scene to an image m_renderer->Present(); // present the image on the display } // syncs with display refresh
A Good Game is a Good Metro style app • Activation • Splash Screen • Loading state • Suspend/resume • Saving State • Screen Layouts • Tiles and Notifications • App Bar • Settings Menu • Sharing
The Splash Screen • Included in your .appx package • Gets displayed by OS before app launch • Covers time spent activating app • App should provide additional cover if it can’t run immediately • No synchronous loading more than 5 sec • Ideal user experience is less than ½ second
Loading Game Assets - Best Practices • Synchronous load on app start (e.g. under OS splash screen) • This can hit the timer, and is not an ideal user experience • Set up a loading screen and load behind that • Delivers user feedback via progress bar • Stream asynchronously to pre-fetch data on demand • Async I/O routines help with this • Procedurally generate content
Process State Transitions App are not notified before they are terminated App gets 5s to work after suspend message suspending Running App Suspended App Terminated App User Launches App Low Memory resuming Apps are notified when they have been resumed
Suspending • Suspend is triggered when app is no longer visible • Time window of no more than 5 seconds • Well-behaved apps should be much faster • Game should stop rendering, save state, and free temp memory • Avoid Termination • App will be terminated if there is memory pressure • App with largest memory usage is the first to get cut • Games often are larger memory users, so free as many resources as possible on suspend (free scratch buffers, etc.)
Add a Suspending Handler CoreApp::Suspending += ref new EventHandler<SuspendingEventArgs^> (this, &myViewObject::Suspending); voidSimple3DGame::OnSuspending( _In_ Platform::Object^ sender, _In_ Windows::ApplicationModel::SuspendingEventArgs^ args) { SuspendingOperation^ op = args->SuspendingOperation; SuspendingDeferral^ deferral = op->GetDeferral(); // Save game state. deferral->Complete(); }
Saving Game State - Best Practices • Level-based: Save state at end of level, or at each checkpoint • Issue: Player will have to replay that level if app gets terminated • Save recent state on Suspending event • Player can continue in the middle of a level, even after a terminate • Need to be quick (5s limit) • Save state opportunistically • Levels, checkpoints, pauses, major events, etc. • Async file routines help here • App Storage APIs • [891] Using Files is the presentation on these
Screen Orientations • Apps can select preferred initial orientation • And can elect not to rotate • Apps can rotate their own rendering based on sensors Landscape Portrait
Fullscreen, Snap and Fill Full Screen Filled Snapped • Apps will get resize events for these • They only occur in landscape orientation • Real-time games can just pause when snapped • Put up status info, etc.
Live Tile • Good place to show the status • What level you are on • Number of friends playing • Time until raid starts Johnny wants to Surf! Connect tubes to get him to the ocean! Tube Rider
Notifications • Notifications = instant news • When someone beats your high score • When a Friend gets an achievement • Notifications must be minimal • Only when user has enabled one • Check out talk <396> on tiles and notifications
Settings Pane • Standard item on ‘Charms Bar’ • Activated by swipe-in from right • Users will know to look here for • In-game options (difficulty) • Input control settings/options • Try not to use for: • Graphics quality settings • System features
Share Provider • This is an ideal mechanism for sending • In-game screenshots • Brag clips • These can go into the user’s libraries or to online apps via the share contract • With a custom version, app can remove text, etc.
Networking • Runtime networking e.g. for multiplayer games • Co-operative, or PVP • API: WinRT Sockets, WebSockets • Simplified syntax, transparent NAT traversal • See talk [580] • Xbox LIVE multiplayer APIs • See talk [756] Building Xbox LIVE Games for Windows 8
Connected Services • Windows Live • Live ID, SkyDrive, Windows 8 roaming state service • Windows Store • See store talk [121] • Xbox LIVE for Windows • See talk [756] Building Xbox LIVE Games for Windows 8 • Azure • Talk [871] Building Social Games for Windows 8 with Windows Azure
Roaming State • Basic service is a part of Windows 8 • [402] Deep Dive on Application Data Roaming • [475] Create App Experiences that Span Time and Space • Broader set of services available from Xbox Live • Already announced
Visual Studio 11 for Windows 8 Dev Preview • Enhanced with new game-oriented features: • Updated C++ language support • File->New Project templates for Direct3D and DX native C++ apps • DirectX HLSL shader compilation and syntax highlighting • Packaging compiled HLSL shaders into the .appx package • Support for other asset types in MSBUILD and previewer • Visualization, processing and packaging of • Textures, meshes, shaders, and audio • Debugging DirectX API calls • Separate talk <761>
Typical Game Components Your Killer Game Graphics Game Input Cut Scenes Audio Tools Local Services Connected Services Sound FX User ID 3-D Touch Streaming Activation Compilers Sensors Effects Storage Music Distribution Debuggers 2-D, Text Search & Settings … Game Controllers Asset Processors UI Controls Roaming
Windows 8 Game Platform Technologies Your Killer Game Graphics Movies & Cut Scenes Tools Game Input Connected Services Audio Local Services Visual Studio Direct3D DirectX Video Pointer Point Windows Live XAudio PLM SensorAPI Windows Store Asset Viewers Direct2D Media Foundation AppData WASAPI XInput XBox Live Contracts Asset Processors TBA
Windows 8 provides all the features you need for a Metro style game Go for it!
For more information DOCUMENTATION & ARTICLES Build your first Metro style game with DirectX Creating a DirectX game Developing the Metro style Marble Maze game with DirectX Creating a Metro style JavaScript Game
thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback
© 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.