WPH310. Free Phone! Windows Phone 7 as a Game Platform Free Tools to Build Great Games The Game Loop...
-
Upload
emma-thornton -
Category
Documents
-
view
222 -
download
2
Transcript of WPH310. Free Phone! Windows Phone 7 as a Game Platform Free Tools to Build Great Games The Game Loop...
Building Your First Windows Phone Game with XNA
Rob CameronArchitect EvangelistMicrosoft
WPH310
Free Phone!
Stay to the End to Win!
Building your First Windows Phone Game with XNAAgenda
Windows Phone 7 as a Game Platform
Free Tools to Build Great Games
The Game LoopLoading ContentUpdate EventDraw Event
Input on Windows Phone 7
Building a Game with Your Friend AppHub
The Windows Phone Hardware
Display
480x800 QVGA
Capacitive touch
4 or more contact points
Sensors
A-GPS, Accelerometer, Compass, Gyro
Camera
5 mega pixels or moreDedicated camera button
Hardware buttons
Start, Search, Back
CPU
ARMv7 Cortex/Scorpion 1G or higherQualcomm MSM7x30, MSM8x55 800Mhz or higher
GPU
DirectX 9 acceleration
Multimedia
Common detailed specsCodec acceleration
Memory
256MB RAM or more8GB Flash or more
Windows Phone 7 as a Game Platform
5
Consistent hardware across OEMs
Performance is impressive, especially in 3D
Xbox Live is a key platform feature
Great tooling to facilitate game development
XNA Game Studio 4.0
Develop games for
Windows PhoneSimplified graphics
API’s
Visual Studio 2010
integration
Enhanced audio
support
New configurable
effects
Game Loop Overview
7
Initialize Engine Load Resources
Free Resources
Get User Input
Calculate
Test Criteria
Give FeedBack
Typical Game LoopAll games do three thingsLoad content when they startUpdate the game world as quickly as possibleDraw the game world as quickly as possible
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
XNA Framework Game Loop Overview
8
Initialize() LoadContent()
UnLoadContent()
XNA Framework Game LoopAll games do three thingsLoad content when they startUpdate the game world as quickly as possibleDraw the game world as quickly as possible
XNA Framework provides the game loop framework on Windows Phone 7
Updatet()
Draw()
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
LoadContent Method
protected override void LoadContent(){ // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here backgroundTexture = Content.Load<Texture2D>("Sprites\\background");}
Update and Draw Methods
Update() Method – Determines StateHandle inputCalculate movementDetermine collisionsUpdate animations and effects
Draw() Method – Renders SceneLoop through objects and draw
Update and Draw Methods
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 base.Draw(gameTime);}
Game Development Process
Drawing Sprites
Moving Sprites
Create a Game Object
Handling Input
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
Drawing Sprites and Textures
protected override void Draw(GameTime gameTime){ 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);}
Moving Sprites
2D games are a great way to start game development
Cartesian coordinate system
Track position, direction, and speed for each object
Moving Objects
Vectors represent position and speed
Position Vector (10,10) – location on screen
Velocity Vector (0,10) – direction and speed
Moving Objects
Vectors represent position and speed
Changing length of velocity vector changes speed
positionVector += velocityVector
Demo
XNA Framework Basics
Game Object
Game objects make game development manageableEncapsulationInheritanceAll that good OO stuff
Implements mini game loopLoad contentUpdateDraw
Working with Game Objects
public override void Update(GameTime gameTime){ CheckForCollisions(); heroShip.Update(gameTime); statusBoard.Update(gameTime);
for (int i = 0; i < maxEnemies; i++) { enemies[i].Update(gameTime); } base.Update(gameTime);}
Working with Game Objects
Demo
Handling Input – Touch
Can capture up to four touch locationsDeclare a TouchCollectionTouchPanel.GetSate() to return a TouchCollection in Update()
Each TouchLocation has stateTouchLocationState.Invalid, Moved, Pressed, ReleasedA single user touch results in two TouchLocation items
One for Pressed, and one for Released
Handle Input – Accelerometer
Values for each axis are in the same range-1 to +1 in each axis
The Accelerometer can measure acceleration in X, Y, and Z
A value of 1 means 1G G is the acceleration due to gravity
Handling Input
Demo
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
Integrating App Hub Samples
Demo
Takeaways
Game Development is fun!
XNA Game Studio provides a powerful development tool
App Hub provides many great samples to get you started
Q&A
Questions?
And please fill out your evaluation form!
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
Track Resources
AppHub – http://create.msdn.com
Design Resources for WP7
Windows Phone 7 Development Documentation
Windows Phone 7 Training Kit
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
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
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
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
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
Windows Phone 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
Win a Windows Phone Contest
QUESTIONS?
Go to the WPC Information Counter
at the TLC
HAT CONTEST*
How do you enter?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?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
SESSION CONTEST*
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
* Restrictions apply please see contest rules for eligibility and restrictions. Contest rules are displayed in the Technical Learning Center at the WPH info counter
Resources
www.microsoft.com/teched
Sessions On-Demand & Community Microsoft Certification & Training Resources
Resources for IT Professionals Resources for Developers
www.microsoft.com/learning
http://microsoft.com/technet http://microsoft.com/msdn
Learning
http://northamerica.msteched.com
Connect. Share. Discuss.
Complete an evaluation on CommNet and enter to win!
Scan the Tag to evaluate this session now on myTech•Ed Mobile
© 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.