WPH307: Building Windows Phone 7 Games with XNA Game Studio

advertisement
Windows Phone 7– A new beginning
Xbox LIVE overview
XNA Game Studio 4.0
Powerful, Productive, Portable
XNA Framework
Call to action and resources
Without Xbox LIVE You can still write and
publish games for Windows Phone
Find a publisher!
Lots to choose from!
We’re interested in your great games!
wpgames@microsoft.com
Create great games for marketplace
http://developer.windowsphone.com
Consistent sets of hardware
capabilities defined by Microsoft
Resolution
Touch Input
CPU / GPU
RAM
Hardware keyboard is optional
Modern XAML/event-driven
application UI framework
Rapid creation of visually rich apps
HTML/Javascript
Mature, robust, widely
deployed technology
APPLICATIONS
GAMES
(and games)
(and applications)
Powerful
Productive
Portable
Makes game development easier
XNA Framework provides robust APIs for games
C#, .NET and Visual Studio tooling
Solutions for game content processing
Not an engine solution
Creating
Games
Develop for
Windows Phone
7 Series
Enhanced audio
support
Simplified
graphics API’s
Visual Studio 2010
integration
New
configurable
effects
Powerful
Windows Phone 7
Uses the .NET platform
Managed code platform, no unsafe code
XNA Game Studio 4.0 is C# exclusive
.NET/XNA is used
for games today!
800+ managed code
games on XBLA/XBLIG
Windows games published
through portals
Frameworks designed
Frameworks
designed
for performance
for performance
XNA
Framework designed
Frameworks
designedfor
gaming scenarios
for performance
Commitment designed
to future
Frameworks
of managed code
for performance
No unnecessary
garbage generation
Three + years of profiling
and investment
We’ve built for performance on
Windows Phone 7
Math libraries optimized
Efficient APIs with tuned
transitions to native code
Productive
Productive development with .NET and C#
High performance IDE
Intellisense makes coding faster
Integrated build/deploy/debug experience
MSBuild engine for build automation
Manage assets in Visual Studio
Importers for common game data formats
Optimize data into binary format for efficient loading
Fully extensible
XNA Framework/Game Loop not required
Content projects external in XNA Game Studio 4.0
XNA Framework
The XNA Framework Game Loop is layered on top of the
Silverlight Application object on Windows Phone 7
Provides the bulk of integration of API’s
Most of the XNA Framework can be accessed from
Silverlight applications
Including Gamer Services (Xbox LIVE)
In this release some sharing/composition is not complete
Scenes using GraphicsDevice from XNA Framework and
UIElements from Silverlight
You’ll want to choose the technology that works
best for your scenarios
Graphics
UI control heavy consider Silverlight
Desire vector graphics in XAML
Media
Rich video support in application
Tooling
If you use Microsoft Blend in your pipeline
Graphics
Using 3D graphics
Sprite heavy 2D applications should consider
the XNA Framework Game Loop
Simulation/Drawing
Those who prefer a traditional update/
draw/present frame loop
Tooling
Those who want to use the XNA Framework
Content Pipeline graphics types
XNA Framework Game Loop Example
Traditional update/draw/
present frame loop
Core programming model consistent
with previous releases
Changes implemented yield better
power performance on devices
System integration with
Windows Phone 7 best practices
protected override void Update(GameTime gameTime)
{
// 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(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
Translated to existing
XNA Framework concepts
base.Draw(gameTime);
}
Graphics
Evolution of our existing immediate mode rendering API
Simplifies for resource and render state management
Feature segmentation between “Reach”/“HiDef” profiles
Rendering primitives 2D and 3D
BasicEffect
SkinnedEffect
New configurable effect
classes on all platforms
Custom effects not available on
Windows Phone 7
EnvironmentMapEffect
DualTextureEffect
AlphaTestEffect
Write your game without worrying about native resolution or orientation
Automatic rotation between portrait and landscape
Touch automatically supports both scale and orientation changes
Scaler can drastically improve performance
Trade off performance for “crispness” and shade fewer pixels
800x480 = 384,000 pixels, 480x320 = 153,600 pixels
Upsample an arbitrary back buffer to native device resolution
Far higher quality than bilinear filtering
Allows for easier porting from other platforms
Scaling/Rotation comes for “free” from Hardware
Audio & Media
Audio Capture Example
Audio Capture and Playback
Simple API to play back WAV data
Modify pitch, volume, pan audio
Ability to play synthesized/buffered audio
public void EventDrivenCapture()
{
mic = Microphone.Default;
buffer = new byte[mic.GetSampleSizeInBytes(mic.BufferDuration)];
mic.BufferReady += new EventHandler(OnBufferReady);
DynamicPlayback = new DynamicSoundEffectInstance(mic.SampleRate,
AudioChannels.Mono);
}
public void OnBufferReady(object sender, EventArgs args)
{
// Get the latest captured audio.
int duration = mic.GetData(buffer);
// Do some post-capture processing and playback.
MakeMeSoundLikeARobot(buffer, duration);
DynamicPlayback.SubmitBuffer(buffer);
Serialize captured data
Provides more control over System.Media
types on Windows Phone 7
}
Audio Playback Example
Microphone/Bluetooth Support
Playback through headset
Capture through mic or headset
// Load a sound effect from a raw stream
SoundEffect effect1 =
SoundEffect.FromStream(GetStreamFromTheWeb("http://url.wav"));
effect1.Play();
// Create dynamic audio on the fly
byte[] fluteSound = GetFluteNote();
effect2 = new SoundEffect(fluteSound, SampleRate, AudioChannels.Stereo);
SoundEffectInstance instance = effect2.CreateInstance();
instance.Pan = -1; instance.Pitch = 1.5f;
instance.Play();
Music Enumeration and Playback
Control and enumerate users’
media within a game
Ability to play songs from URI/URL
(i.e. music app)
URI Song Playback Example
// Constructs a song from a URI
Uri mediaStreamUri = new Uri("http://song.asx");
Song streamedSong = Song.FromUri("Song",
mediaStreamUri);
// Play the song
MediaPlayer.Play(streamedSong);
Picture Enumeration and Playback
Supports photo picking/editing/publishing
Video Playback
Uses standard video player API
Show/Hide controls
Retrieve Image Data
MediaLibrary media = new MediaLibrary();
// Get the JPEG image data
Stream myJpegImage = ReadAndModifyPicture(somePicture);
// Save texture to Media Library
media.SavePicture("Awesome", myJpegImage);
Input / Touch
Cross Platform Input API
Xbox 360 Controllers
(Xbox/Windows)
Touch Input Handling
Keyboard
(Xbox/Windows/Windows Phone 7)
var touchCollection = TouchPanel.GetState();
Touch API
//...
Available across platforms for portability
(fewer #ifdefs)
foreach (var touchLocation in touchCollection)
{
if (touchLocation.State ==
TouchLocationState.Released)
{
//...
}
}
Multipoint on Windows Phone 7
and Windows
Orientation and resolution aware
Developer can override
Sensors
Leverage Platform Features on
Windows Phone 7
Location
Accelerometer
VibrationExample
VibrateController rumbler;
rumbler.Start(TimeSpan.FromSeconds(2));
Vibration
Accelerometer Example
Accelerometer accelerometer = new Accelerometer();
accelerometer.ReadingChanged +=
AccelerometerReadingChanged;
accelerometer.Start();
Xbox LIVE
Windows Phone 7 OS
HTTP
Push
Xbox LIVE
Avatars
Invites
Gamer Services
Profile
Achievements
Leaderboards
Trial
Mode
Read a Player’s Profile
// Profile access
SignedInGamer gamer = Gamer.SignedInGamers[0];
// Get the player's GamerTag to display
string gamerTag = gamer.Gamertag;
// A SignedInGamer has a Profile
GamerProfile profile = gamer.GetProfile();
// Get the player's current GamerScore
int gamerScore = profile.GamerScore;
// get the gamer picture (PNG file stream)
Stream gamerPictureStream = profile.GamerPicture;
Award an Achievement
// Award an achievement
SignedInGamer gamer = Gamer.SignedInGamers[0];
gamer.AwardAchievement("Attended TechEd 2010");
Read Achievements
// Get achievements
AchievementCollection achievements = gamer.GetAchievements();
// walk through achievements
foreach (Achievement a in achievements)
{
string name = a.Name;
string description = a.Description;
bool earned = a.IsEarned;
int score = a.GamerScore;
Stream icon = a.Picture;
}
Write to a Leaderboard
// Create leaderboard identity with game mode 1
LeaderboardIdentity id =
LeaderboardIdentity.Create(LeaderboardKey.BestScoreLifeTime, 1);
// get the leaderboard writer from the signed in gamer
LeaderboardWriter writer = gamer.LeaderboardWriter;
// get the leaderboard entry for the identity
LeaderboardEntry entry = writer.GetLeaderboard(id);
// write new leaderboard data
entry.Rating = 1000;
entry.columns.SetValue("Outcome", LeaderboardOutcome.Win);
Read From a Leaderboard
// Read from leaderboard with page size of 10
LeaderboardReader reader = LeaderboardReader.Read(id, gamer, 10);
foreach (LeaderboardEntry e in reader.Entries)
{
// score or time, as defined by identity. Rating determines rank.
long rating = e.Rating;
// read additional column data
long wins = e.Columns.GetValueInt64("Wins");
Stream blob = e.Columns.GetValueStream("Blob");
}
reader.PageDown();
Trial Mode
Guide.SimulateTrialMode = true;
// if we are in trial mode, show a marketplace offering
if (Guide.IsTrialMode)
{
PlayerIndex playerIndex = Gamer.SignedInGamers[0].PlayerIndex;
Guide.ShowMarketplace(playerIndex);
}
http://avatar.xboxlive.com/avatar/Major%20Nelson/avatar-body.png
Portable
XNA Framework designed
to be cross platform
Smaller time investment
and target more sockets
Project synchronization
between platforms
Reach
Designed for compatibility across screens/devices
This profile includes Windows Phone 7
HiDef
Platform showcase features
Xbox 360/Windows Only
Summary
Powerful
Great managed code games, working today
Windows Phone provides a powerful platform for gaming
Productive
Focus on being a game developer
Great tools make you more productive
Portable
Target more platforms easily
Focus on your game differences, not the technology
Call to Action
Download the Windows Phone Developer Tools
http://developer.windowsphone.com
Create awesome games!
Peer Support @
http://forums.xna.com
Hundreds of samples
Lots of MVPs and experts to help
you get started
Blogs
Contact Microsoft
XNA Creators Club @
http://creators.xna.com
Email:
wpgames@microsoft.com
Team Blog @
http://blogs.msdn.com/xna/
On the web:
http://developer.windowsphone.com
Shawn Hargreaves @
http://blogs.msdn.com/shawnhar/
(Great Tech Info!)
Monday
WPH202
WPH301
Tuesday
WPH302
WPH313
WPH304
WPH305
WPH306
Deploying Windows Phone 7 with Exchange Server and SharePoint Server
WP7: Deploy Microsoft Forefront Unified Access Gateway for Access Control
to SharePoint, Exchange and more.
Overview of the Windows Phone 7 Application Platform
Windows Phone 7 Architecture Deep Dive
An In-Depth view at Building Applications for WP7 with Silverlight (Part 1)
An In-Depth view at Building Applications for WP7 with Silverlight (Part 2)
Developing Occasionally Connected Applications for Windows Phone 7
Wednesday
WPH310
WPH311
WPH309
WPH307
WPH308
Designing and Developing for the Rich Mobile Web
Developing Mobile Code Today that will run on WP 7 Tomorrow
Silverlight performance on Windows Phone
Building Windows Phone Games with XNA
Building a High Performance 3D Game for Windows Phone
Thursday
WPH303
WPH314
WPH312
Understanding the Windows Phone 7 Development Tools
Learn Windows Phone 7 Development by Creating a Robotic T-Shirt Cannon
Understanding Marketplace and Making Money with WP7 Applications
Questions? Demos? The Latest phones?
www.windowsphone.com/business
developer.windowsphone.com
www.windowsphone7.com
Hat Contest*
Session Contest*
Questions?
* Restrictions apply please see contest rules for eligibility and restrictions. Contest rules are displayed in the Technical Learning Center at the WPH info counter.
– Breakout Sessions Mon &Tue
Monday
WPH301
WPH202
WP7: Deploy Microsoft Forefront Unified Access Gateway for Access Control
to SharePoint, Exchange and more.
Deploying Windows Phone 7 with Exchange Server and SharePoint Server
Tuesday
WPH203
WPH313
WPH304
WPH305
WPH306
Overview of the Windows Phone 7 Application Platform
Windows Phone 7 Architecture Deep Dive
An In-Depth view at Building Applications for WP7 with Silverlight (Part 1)
An In-Depth view at Building Applications for WP7 with Silverlight (Part 2)
Developing Occasionally Connected Applications for Windows Phone 7
– Breakout Sessions Wed &Thu
Wednesday
WPH310
WPH311
WPH309
WPH307
WPH308
Designing and Developing for the Rich Mobile Web
Developing Mobile Code Today that will run on WP 7 Tomorrow
Silverlight performance on Windows Phone
Building Windows Phone Games with XNA
Building a High Performance 3D Game for Windows Phone
Thursday
WPH303
WPH314
WPH312
Understanding the Windows Phone 7 Development Tools
Learn Windows Phone 7 Development by Creating a Robotic T-Shirt Cannon
Understanding Marketplace and Making Money with WP7 Applications
– Interactive Session & HOL
Windows Phone Interactive Sessions
Windows Phone Hands On Labs
www.microsoft.com/teched
www.microsoft.com/learning
http://microsoft.com/technet
http://microsoft.com/msdn
Sign up for Tech·Ed 2011 and save $500
starting June 8 – June 31st
http://northamerica.msteched.com/registration
You can also register at the
North America 2011 kiosk located at registration
Join us in Atlanta next year
Download