$10b in game software per year worldwide 145m active gamers in us alone over 50% of all current...

44
www.buildwindows.com Build your first Metro style game Chas. Boyd Principal Program Manager, Graphics Microsoft Corporation PLAT-750T

Upload: nicholas-sullivan

Post on 28-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

www.buildwindows.com

Build your first Metro style game

Chas. BoydPrincipal Program Manager, GraphicsMicrosoft Corporation

PLAT-750T

www.buildwindows.com

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

www.buildwindows.com

Windows 8 has everything you need to write and ship a game to millions of

customers

www.buildwindows.com

MarbleMaze

Chas. BoydPrinciple Program ManagerWindows Graphics

demo

www.buildwindows.com

Typical Game Components

Cut Scenes

Your Killer Game

Game Input

Graphics Audio

3-DStreami

ngTouch

Activation

Sound FX

User ID

Connected

Services

Local Services

2-D, Text

Game Controll

ers

Sensors MusicDistribut

ion

RoamingUI

Controls

Effects StorageSearch

& Setting

s …

Compilers

Debuggers

Asset Process

ors

Tools

Graphics

www.buildwindows.com

DirectX is Direct Access to Hardware

• Games require smooth interaction -> fast graphics

• DirectX gives you control of the low-level hardware

www.buildwindows.com

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>

www.buildwindows.com

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

www.buildwindows.com

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 and Video

www.buildwindows.com

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

www.buildwindows.com

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>

www.buildwindows.com

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 Loopusing 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

Local Windows Services

www.buildwindows.com

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

www.buildwindows.com

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

www.buildwindows.com

Loading Game Assets - Best Practices

1. Synchronous load on app start (e.g. under OS splash screen)• This can hit the timer, and is not an ideal user experience

2. Set up a loading screen and load behind that• Delivers user feedback via progress bar

3. Stream asynchronously to pre-fetch data on demand• Async I/O routines help with this

4. Procedurally generate content

www.buildwindows.com

Process State Transitions

RunningApp

Suspended

App

suspending Terminated

App

Low Memoryresuming

App gets 5s to work after suspend

message

App are not notified before

they are terminated

Apps are notified when they have been resumed

User Launche

s App

www.buildwindows.com

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 HandlerCoreApp::Suspending += ref new EventHandler<SuspendingEventArgs^>

(this, &myViewObject::Suspending);

void Simple3DGame::OnSuspending( _In_ Platform::Object^ sender, _In_ Windows::ApplicationModel::SuspendingEventArgs^ args ){ SuspendingOperation^ op = args->SuspendingOperation; SuspendingDeferral^ deferral = op->GetDeferral();

// Save game state.

deferral->Complete();}

www.buildwindows.com

Saving Game State - Best Practices

1. Level-based: Save state at end of level, or at each checkpoint• Issue: Player will have to replay that level if app gets

terminated2. 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)

3. 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

www.buildwindows.com

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

www.buildwindows.com

Fullscreen, Snap and Fill

• 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.

Snapped Filled Full Screen

www.buildwindows.com

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

www.buildwindows.com

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

www.buildwindows.com

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

www.buildwindows.com

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.

www.buildwindows.com

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

www.buildwindows.com

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

www.buildwindows.com

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

Tools

www.buildwindows.com

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>

www.buildwindows.com

Typical Game Components

Cut Scenes

Your Killer Game

Game Input

Graphics Audio

3-DStreami

ngTouch

Activation

Sound FX

User ID

Connected

Services

Local Services

2-D, Text

Game Controll

ers

Sensors MusicDistribut

ion

RoamingUI

Controls

Effects StorageSearch

& Setting

s …

Compilers

Debuggers

Asset Process

ors

Tools

www.buildwindows.com

Windows 8 Game Platform Technologies

Movies & Cut

Scenes

Your Killer Game

Game Input

Graphics Audio

Direct3DDirectX Video

PointerPoint PLMXAudio

Windows Live

Connected

Services

Local Services

Direct2D

XInput

SensorAPI WASAPI

Windows Store

XBox LiveTBA

Media Foundati

onAppData

Contracts

Visual Studio

Asset Viewers

Asset Processor

s

Tools

www.buildwindows.com

Windows 8 provides all the features you need

for a Metro style game

Go for it!

www.buildwindows.com

Game developer cheat sheetFeature Solution # Talk Sample

Graphics DirectX PLAT-766T Introduction to DirectX for Metro style apps

3D Rendering Direct3D PLAT-751T 3D Graphics in Metro Style Apps and Games Simple3DGame

Asset Processing VS11 TOOL-761T

A lap around DirectX game development tools ResourceLoading

3D Performance Direct3D11

PLAT-752T Tuning GPU usage for any form factor Simple3DGame

2D, Text, Imaging

Direct2D PLAT-769T Achieving high performance 2D graphics with Direct2D

C++ Language VS11 C++

TOOL-532T

Using the Windows Runtime from C++

IDE and Debugging

VS11 TOOL-761T

A lap around DirectX game development tools File->New Project

Touch PointerPoint

APP-186T Build advanced touch apps in Windows 8 Simple3DTouch

Accelerometer/Gyro

SensorAPI PLAT-781T Using location & sensors in your app MarbleMaze

Game Input XInput PLAT-754T From touch to gamepads: master player input in your Metro style game

SimpleController

Game Audio&Video

XAudio2 PLAT-755T Compelling audio and video for Metro style games BasicSound

Networking WebSockets

PLAT-580T Building Windows runtime sockets apps

Xbox Services XBoxLive PLAT-756T Building Xbox LIVE games for Windows 8

OS Services Windows 8

All BUILD Conference

www.buildwindows.com

• Feedback and questions http://forums.dev.windows.com

• Session feedbackhttp://bldw.in/SessionFeedback

thank you

© 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.