SlideShare a Scribd company logo
1 of 32
XNA for
Windows Phone
Ed Donahue
Academic Developer Evangelist

ed.donahue@microsoft.com
creepyed.com | @creepyed
Topics
• Available sensors and tools
• The game loop
• Adding movement
• Add-ins
• Demos available here: http://bit.ly/EdDemos




Windows Phone
The Windows Phone Hardware




Windows Phone
XNA Game Studio 4.0




Windows Phone
Quick overview of XNA
• The XNA Framework provides everything you need
  to get started writing games:
• Full Content Management (integrated into Visual
  Studio)
• Support for 2D Sprite-based gameplay
• Support for 3D games
• Common behaviours across the Windows PC,
  Xbox 360 and Windows Phone
    –   One game engine can run on all platforms
• Well factored object model
Windows Phone
3D Games
• XNA provides full support for 3D games including
  the use of 3D models in gameplay
• The hardware acceleration provides very
  impressive, high performance graphics
• You can make use of a number of pre-build
  shaders that have been specifically optimised for
  phone use




Windows Phone
Game Loop Overview


                Initialize         Load        Get User
                 Engine          Resources      Input


                                               Calculate


                                              Test Criteria


                                                Give
                             Free Resources   FeedBack




Windows Phone
Game Loop Overview

                          XNA Framework Game Loop
                Initialize()      LoadContent()
                                                  Update()




                                                  Draw()
                               UnloadContent()




Windows Phone
Creating a game world
• An XNA game uses a number of variables to
  represent the state of the game itself
    –   The Update method will update their values
    –   The Draw method will produce a display that reflects
        their value
• In the case of Cheese Roller the game must
  manage the texture and draw position of the
  cheese on the screen



Windows Phone
Demo

Drawing Cheese
Windows Phone and orientation




• By default a Windows Phone XNA game assumes
  it is running in “landscape” mode with the screen
  on the left of the controls
• I want to change this, because I want to send the
  cheese down the long axis of the phone when it is
  rolled
• I can select orientation when the game starts
Windows Phone
Orientation management
• An XNA game can specify the orientations it can
  support
• The game can bind a method to the event which is
  fired when the orientation changes
   –   Games can animate the transition to the new orientation
       if they wish
• When orientation changes the origin for the draw
  position is moved to the top left hand corner of the
  viewport
• The frame of reference for accelerometer readings
   (of which more later) is for the phone held in
Windows Phone
Size and the scaler
• An XNA game can also request a specific size of
  back buffer for the display
• The game will be given this resolution irrespective
  of the actual device
   –   The Graphics Processor (GPU) performs this scaling
       automatically and interpolates to remove any jagged
       edges
• This is a great way to get performance boost by
  rendering to a lower resolution than the screen
  itself
   –    In a fast moving game the lower resolution is not
Windows noticeable
        Phone
Demo

Orientation and Scale
Adding Movement
     • 2D games are a great way to start game
       development
     • Cartesian coordinate system
     • Track position, direction, and speed for each object




15   Windows Phone
Moving Objects
• Vectors represent position and speed
• Position Vector (10,10) – location on screen
• Velocity Vector (0,10) – direction and speed




Windows Phone
Moving Objects
• Vectors represent position and speed
• positionVector       velocityVector
• Changing length of velocity vector changes speed




Windows Phone
Windows phone gesture support
     • For the ultimate in control you can get direct
       access to touch events from the panel
         –   Up to four events can be tracked at one time
         –   Each event is uniquely identified throughout its lifetime
     • However, XNA games can also use built in gesture
       recognition
     • Register an interest in a particular gesture type and
       then get notification when one has been performed



18   Windows Phone
Supported gestures
     • The touch panel can detect a number of different
       gestures including
         – Tap
         – DoubleTap
         – Hold
         – HorizontalDrag, VerticalDrag and FreeDrag
         – Pinch
         – Flick

     • The Cheese Roller game is going to use the Flick
       gesture

19   Windows Phone
Registering an interest in a
gesture
TouchPanel.EnabledGestures = GestureType.Flick;




• The game must select those gestures that it wants
  to use
• This can be done once at the start of the game
• I do it in the XNA Initialize method
• A game can also query the TouchPanel about the
  number of points it can track simultaneously


Windows Phone
Demo

Flicking Cheese
Improving on cheese roller
• The obvious improvement to Cheese Roller is to add
  more cheese
• If we do this the physics becomes more complicated
• Fortunately there are a lot of engines out there that can
  help
• One of these is the Farseer engine
• It is a 2D physics engine that is very easy to use and
  works well on Windows Phone
• The Farseer Physics Engine is a Codeplex based
  project you can download from here:
Windows Phone   http://farseerphysics.codeplex.com/
Using the phone accelerometer
• You can also use the accelerometer to control the
  behavior of objects in your game
• The Accelerometer can measure acceleration in X,
  Y and Z
• You can use just the X and Y values to turn it into a
  replacement for a gamepad
• The values that are returned are in the same
  range:
  -1 to +1 in each axis

Windows Phone
XNA Framework Accelerometer
• Unlike other XNA input devices the accelerometer
  in XNA 4.0 is event driven
• The accelerometer generates events when new
  readings are available
• You must bind a method to the event
• The method can store the settings for later use




Windows Phone
Demo

Tipping Cheese
Adding sound effects
• Sound effects can be added to
  games as additional resources
• They are loaded into the
  Content project and provided
  to the game by the Content
  Manager




Windows Phone
Music Playback
• An XNA game can also play back music files
• These can be loaded from content which is part of
  the game assets or from the media collection on
  the phone
• It is also possible to load the album artwork and
  use this in games
• Music is played by the MediaPlayer object, and is
  not managed in the same way as sound effects


Windows Phone
Demo

Sound Effects
XNA Framework and
  Fast Application
    Switching
XNA Framework application
switching
• There is a useful MSDN document that explains
  how to persist and recover XNA games :


                http://bit.ly/soN67r




Windows Phone
Review
• The Windows Phone platform provides a mix of
  resources that can be used to create compelling
  games
• The Touch sensor and accelerometer inputs are
  easy to use in XNA programs
• It is easy to add sound and music to gameplay




Windows Phone
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.




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

More Related Content

What's hot

OGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_Glooops
OGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_GlooopsOGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_Glooops
OGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_GlooopsBuff Nguyen
 
Unity 3D
Unity 3DUnity 3D
Unity 3Dgema123
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDLWingston
 
F2P Game Balancing: Data Movies
F2P Game Balancing: Data MoviesF2P Game Balancing: Data Movies
F2P Game Balancing: Data MoviesThomas Hulvershorn
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Karsten Wysk
 
Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...danielandlubo
 
Macbook Function Keys Explained
Macbook Function Keys ExplainedMacbook Function Keys Explained
Macbook Function Keys ExplainedMike Glennon
 
GameMaker:Studio and Windows
GameMaker:Studio and Windows GameMaker:Studio and Windows
GameMaker:Studio and Windows Lee Stott
 
Cmd unity withc
Cmd unity withcCmd unity withc
Cmd unity withcumairnoora
 
Gamemaker - Intro and Core Objects
Gamemaker - Intro and Core ObjectsGamemaker - Intro and Core Objects
Gamemaker - Intro and Core ObjectsJoe Healy
 
One Handed Controller
One Handed ControllerOne Handed Controller
One Handed Controllerzaxxor1
 
Strike dream name_week2assignment_0315 (1)
Strike dream name_week2assignment_0315 (1)Strike dream name_week2assignment_0315 (1)
Strike dream name_week2assignment_0315 (1)thoffman7411
 
Mobile Game Analytics: Presentation by Outplay at Games Analytics and BI Forum
Mobile Game Analytics: Presentation by Outplay at Games Analytics and BI ForumMobile Game Analytics: Presentation by Outplay at Games Analytics and BI Forum
Mobile Game Analytics: Presentation by Outplay at Games Analytics and BI ForumThomas Hulvershorn
 
Developing Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3DDeveloping Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3DAdrian Popovici
 
Linux userguide
Linux userguideLinux userguide
Linux userguidelogan159
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA GameSohil Gupta
 

What's hot (19)

OGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_Glooops
OGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_GlooopsOGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_Glooops
OGDC2012 Just-in-time Operation in Social Games_Mr.Eiji Okuda_Glooops
 
Unity 3D
Unity 3DUnity 3D
Unity 3D
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
 
XO tutorial March '08
XO tutorial March '08XO tutorial March '08
XO tutorial March '08
 
F2P Game Balancing: Data Movies
F2P Game Balancing: Data MoviesF2P Game Balancing: Data Movies
F2P Game Balancing: Data Movies
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011
 
Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...Creating a serious game with the Unity 3D Game Engine and the importance of m...
Creating a serious game with the Unity 3D Game Engine and the importance of m...
 
Macbook Function Keys Explained
Macbook Function Keys ExplainedMacbook Function Keys Explained
Macbook Function Keys Explained
 
Playstation Cerberus
Playstation CerberusPlaystation Cerberus
Playstation Cerberus
 
GameMaker:Studio and Windows
GameMaker:Studio and Windows GameMaker:Studio and Windows
GameMaker:Studio and Windows
 
Cmd unity withc
Cmd unity withcCmd unity withc
Cmd unity withc
 
Gamemaker - Intro and Core Objects
Gamemaker - Intro and Core ObjectsGamemaker - Intro and Core Objects
Gamemaker - Intro and Core Objects
 
project
projectproject
project
 
One Handed Controller
One Handed ControllerOne Handed Controller
One Handed Controller
 
Strike dream name_week2assignment_0315 (1)
Strike dream name_week2assignment_0315 (1)Strike dream name_week2assignment_0315 (1)
Strike dream name_week2assignment_0315 (1)
 
Mobile Game Analytics: Presentation by Outplay at Games Analytics and BI Forum
Mobile Game Analytics: Presentation by Outplay at Games Analytics and BI ForumMobile Game Analytics: Presentation by Outplay at Games Analytics and BI Forum
Mobile Game Analytics: Presentation by Outplay at Games Analytics and BI Forum
 
Developing Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3DDeveloping Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3D
 
Linux userguide
Linux userguideLinux userguide
Linux userguide
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA Game
 

Similar to XNA for Windows Phone

Zadar Developers Hub - Windows Phone Development
Zadar Developers Hub - Windows Phone DevelopmentZadar Developers Hub - Windows Phone Development
Zadar Developers Hub - Windows Phone DevelopmentNiko Vrdoljak
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeypprem
 
Lecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingLecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingKobkrit Viriyayudhakorn
 
Windows phone 7 xna
Windows phone 7 xnaWindows phone 7 xna
Windows phone 7 xnaGlen Gordon
 
Game Development with Windows Phone 7
Game Development with Windows Phone 7Game Development with Windows Phone 7
Game Development with Windows Phone 7Allan Mangune
 
XNA and Windows Phone
XNA and Windows PhoneXNA and Windows Phone
XNA and Windows PhoneGlen Gordon
 
Developing Apps for Windows Phone 8
Developing Apps for Windows Phone 8Developing Apps for Windows Phone 8
Developing Apps for Windows Phone 8KMS Technology
 
Windows 8 and MonoGame Presentation at Staffordshire University
Windows 8 and MonoGame Presentation at Staffordshire UniversityWindows 8 and MonoGame Presentation at Staffordshire University
Windows 8 and MonoGame Presentation at Staffordshire UniversityLee Stott
 
Design phase of game development of unity 2d game
Design phase of game development of unity 2d game Design phase of game development of unity 2d game
Design phase of game development of unity 2d game Muhammad Maaz Irfan
 
98 374 Lesson 02-slides
98 374 Lesson 02-slides98 374 Lesson 02-slides
98 374 Lesson 02-slidesTracie King
 
S#01 김영욱
S#01 김영욱 S#01 김영욱
S#01 김영욱 codercay
 
Windows Phone Application development
Windows Phone Application developmentWindows Phone Application development
Windows Phone Application developmentvkalve
 
Windows phone app development overview
Windows phone app development overviewWindows phone app development overview
Windows phone app development overviewAlan Mendelevich
 
(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...
(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...
(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...Amazon Web Services
 
Marmalade @include2014 Dev leestott Microsoft
Marmalade @include2014 Dev leestott MicrosoftMarmalade @include2014 Dev leestott Microsoft
Marmalade @include2014 Dev leestott MicrosoftLee Stott
 
Windows Phone 8 App Development
Windows Phone 8 App DevelopmentWindows Phone 8 App Development
Windows Phone 8 App DevelopmentDalpatTapaniya
 
Porting unity games to windows - London Unity User Group
Porting unity games to windows - London Unity User GroupPorting unity games to windows - London Unity User Group
Porting unity games to windows - London Unity User GroupLee Stott
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game EngineDiksha Bhargava
 

Similar to XNA for Windows Phone (20)

Zadar Developers Hub - Windows Phone Development
Zadar Developers Hub - Windows Phone DevelopmentZadar Developers Hub - Windows Phone Development
Zadar Developers Hub - Windows Phone Development
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
 
Lecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingLecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR Programming
 
Windows phone 7 xna
Windows phone 7 xnaWindows phone 7 xna
Windows phone 7 xna
 
Windows Phone Introduction
Windows Phone IntroductionWindows Phone Introduction
Windows Phone Introduction
 
Game Development with Windows Phone 7
Game Development with Windows Phone 7Game Development with Windows Phone 7
Game Development with Windows Phone 7
 
XNA and Windows Phone
XNA and Windows PhoneXNA and Windows Phone
XNA and Windows Phone
 
Developing Apps for Windows Phone 8
Developing Apps for Windows Phone 8Developing Apps for Windows Phone 8
Developing Apps for Windows Phone 8
 
Windows 8 and MonoGame Presentation at Staffordshire University
Windows 8 and MonoGame Presentation at Staffordshire UniversityWindows 8 and MonoGame Presentation at Staffordshire University
Windows 8 and MonoGame Presentation at Staffordshire University
 
Design phase of game development of unity 2d game
Design phase of game development of unity 2d game Design phase of game development of unity 2d game
Design phase of game development of unity 2d game
 
98 374 Lesson 02-slides
98 374 Lesson 02-slides98 374 Lesson 02-slides
98 374 Lesson 02-slides
 
S#01 김영욱
S#01 김영욱 S#01 김영욱
S#01 김영욱
 
Presentación Unity
Presentación UnityPresentación Unity
Presentación Unity
 
Windows Phone Application development
Windows Phone Application developmentWindows Phone Application development
Windows Phone Application development
 
Windows phone app development overview
Windows phone app development overviewWindows phone app development overview
Windows phone app development overview
 
(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...
(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...
(AFF302) Responsive Game Design: Bringing Desktop and Mobile Games to the Liv...
 
Marmalade @include2014 Dev leestott Microsoft
Marmalade @include2014 Dev leestott MicrosoftMarmalade @include2014 Dev leestott Microsoft
Marmalade @include2014 Dev leestott Microsoft
 
Windows Phone 8 App Development
Windows Phone 8 App DevelopmentWindows Phone 8 App Development
Windows Phone 8 App Development
 
Porting unity games to windows - London Unity User Group
Porting unity games to windows - London Unity User GroupPorting unity games to windows - London Unity User Group
Porting unity games to windows - London Unity User Group
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game Engine
 

More from Ed Donahue

AT&T Hackathon Hawaii
AT&T Hackathon HawaiiAT&T Hackathon Hawaii
AT&T Hackathon HawaiiEd Donahue
 
AT&T Hack-o-ween
AT&T Hack-o-weenAT&T Hack-o-ween
AT&T Hack-o-weenEd Donahue
 
AT&T Government Hackathon, Washington DC. 10/6/2017
AT&T Government Hackathon, Washington DC. 10/6/2017AT&T Government Hackathon, Washington DC. 10/6/2017
AT&T Government Hackathon, Washington DC. 10/6/2017Ed Donahue
 
AT&T IoT Civic Hackathon @ IndyPy
AT&T IoT Civic Hackathon @ IndyPyAT&T IoT Civic Hackathon @ IndyPy
AT&T IoT Civic Hackathon @ IndyPyEd Donahue
 
AT&T VR/AR Hackathon - Seattle
AT&T VR/AR Hackathon - SeattleAT&T VR/AR Hackathon - Seattle
AT&T VR/AR Hackathon - SeattleEd Donahue
 
AT&T IoT Hackathon - Dallas (hosted by The DEC)
AT&T IoT Hackathon - Dallas (hosted by The DEC)AT&T IoT Hackathon - Dallas (hosted by The DEC)
AT&T IoT Hackathon - Dallas (hosted by The DEC)Ed Donahue
 
Cisco Lightning Talk
Cisco Lightning TalkCisco Lightning Talk
Cisco Lightning TalkEd Donahue
 
Intel Lightning Talk
Intel Lightning TalkIntel Lightning Talk
Intel Lightning TalkEd Donahue
 
IBM Lightning Talk
IBM Lightning TalkIBM Lightning Talk
IBM Lightning TalkEd Donahue
 
AT&T Public Sector Hackathon
AT&T Public Sector HackathonAT&T Public Sector Hackathon
AT&T Public Sector HackathonEd Donahue
 
AT&T IoT Hackathon - Seattle
AT&T IoT Hackathon - SeattleAT&T IoT Hackathon - Seattle
AT&T IoT Hackathon - SeattleEd Donahue
 
AT&T Shape Hackathon Kick-off
AT&T Shape Hackathon Kick-offAT&T Shape Hackathon Kick-off
AT&T Shape Hackathon Kick-offEd Donahue
 
BIAC Hackathon Kick-off
BIAC Hackathon Kick-offBIAC Hackathon Kick-off
BIAC Hackathon Kick-offEd Donahue
 
BIAC Hackathon Lightning Talks
BIAC Hackathon Lightning TalksBIAC Hackathon Lightning Talks
BIAC Hackathon Lightning TalksEd Donahue
 
AT&T Smart Cities Hackathon
AT&T Smart Cities HackathonAT&T Smart Cities Hackathon
AT&T Smart Cities HackathonEd Donahue
 
AT&T Mobile App & IoT Hackathon @ Catalyst
AT&T Mobile App & IoT Hackathon @ Catalyst AT&T Mobile App & IoT Hackathon @ Catalyst
AT&T Mobile App & IoT Hackathon @ Catalyst Ed Donahue
 
AT&T Mobile App Hackathon (Smart City) - Berkeley
AT&T Mobile App Hackathon (Smart City) - BerkeleyAT&T Mobile App Hackathon (Smart City) - Berkeley
AT&T Mobile App Hackathon (Smart City) - BerkeleyEd Donahue
 
AT&T Mobile App Hackathon - Seattle
AT&T Mobile App Hackathon - SeattleAT&T Mobile App Hackathon - Seattle
AT&T Mobile App Hackathon - SeattleEd Donahue
 
Malvern WOWZAPP Info
Malvern WOWZAPP InfoMalvern WOWZAPP Info
Malvern WOWZAPP InfoEd Donahue
 
Windows 8 Contracts
Windows 8 ContractsWindows 8 Contracts
Windows 8 ContractsEd Donahue
 

More from Ed Donahue (20)

AT&T Hackathon Hawaii
AT&T Hackathon HawaiiAT&T Hackathon Hawaii
AT&T Hackathon Hawaii
 
AT&T Hack-o-ween
AT&T Hack-o-weenAT&T Hack-o-ween
AT&T Hack-o-ween
 
AT&T Government Hackathon, Washington DC. 10/6/2017
AT&T Government Hackathon, Washington DC. 10/6/2017AT&T Government Hackathon, Washington DC. 10/6/2017
AT&T Government Hackathon, Washington DC. 10/6/2017
 
AT&T IoT Civic Hackathon @ IndyPy
AT&T IoT Civic Hackathon @ IndyPyAT&T IoT Civic Hackathon @ IndyPy
AT&T IoT Civic Hackathon @ IndyPy
 
AT&T VR/AR Hackathon - Seattle
AT&T VR/AR Hackathon - SeattleAT&T VR/AR Hackathon - Seattle
AT&T VR/AR Hackathon - Seattle
 
AT&T IoT Hackathon - Dallas (hosted by The DEC)
AT&T IoT Hackathon - Dallas (hosted by The DEC)AT&T IoT Hackathon - Dallas (hosted by The DEC)
AT&T IoT Hackathon - Dallas (hosted by The DEC)
 
Cisco Lightning Talk
Cisco Lightning TalkCisco Lightning Talk
Cisco Lightning Talk
 
Intel Lightning Talk
Intel Lightning TalkIntel Lightning Talk
Intel Lightning Talk
 
IBM Lightning Talk
IBM Lightning TalkIBM Lightning Talk
IBM Lightning Talk
 
AT&T Public Sector Hackathon
AT&T Public Sector HackathonAT&T Public Sector Hackathon
AT&T Public Sector Hackathon
 
AT&T IoT Hackathon - Seattle
AT&T IoT Hackathon - SeattleAT&T IoT Hackathon - Seattle
AT&T IoT Hackathon - Seattle
 
AT&T Shape Hackathon Kick-off
AT&T Shape Hackathon Kick-offAT&T Shape Hackathon Kick-off
AT&T Shape Hackathon Kick-off
 
BIAC Hackathon Kick-off
BIAC Hackathon Kick-offBIAC Hackathon Kick-off
BIAC Hackathon Kick-off
 
BIAC Hackathon Lightning Talks
BIAC Hackathon Lightning TalksBIAC Hackathon Lightning Talks
BIAC Hackathon Lightning Talks
 
AT&T Smart Cities Hackathon
AT&T Smart Cities HackathonAT&T Smart Cities Hackathon
AT&T Smart Cities Hackathon
 
AT&T Mobile App & IoT Hackathon @ Catalyst
AT&T Mobile App & IoT Hackathon @ Catalyst AT&T Mobile App & IoT Hackathon @ Catalyst
AT&T Mobile App & IoT Hackathon @ Catalyst
 
AT&T Mobile App Hackathon (Smart City) - Berkeley
AT&T Mobile App Hackathon (Smart City) - BerkeleyAT&T Mobile App Hackathon (Smart City) - Berkeley
AT&T Mobile App Hackathon (Smart City) - Berkeley
 
AT&T Mobile App Hackathon - Seattle
AT&T Mobile App Hackathon - SeattleAT&T Mobile App Hackathon - Seattle
AT&T Mobile App Hackathon - Seattle
 
Malvern WOWZAPP Info
Malvern WOWZAPP InfoMalvern WOWZAPP Info
Malvern WOWZAPP Info
 
Windows 8 Contracts
Windows 8 ContractsWindows 8 Contracts
Windows 8 Contracts
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

XNA for Windows Phone

  • 1. XNA for Windows Phone Ed Donahue Academic Developer Evangelist ed.donahue@microsoft.com creepyed.com | @creepyed
  • 2. Topics • Available sensors and tools • The game loop • Adding movement • Add-ins • Demos available here: http://bit.ly/EdDemos Windows Phone
  • 3. The Windows Phone Hardware Windows Phone
  • 4. XNA Game Studio 4.0 Windows Phone
  • 5. Quick overview of XNA • The XNA Framework provides everything you need to get started writing games: • Full Content Management (integrated into Visual Studio) • Support for 2D Sprite-based gameplay • Support for 3D games • Common behaviours across the Windows PC, Xbox 360 and Windows Phone – One game engine can run on all platforms • Well factored object model Windows Phone
  • 6. 3D Games • XNA provides full support for 3D games including the use of 3D models in gameplay • The hardware acceleration provides very impressive, high performance graphics • You can make use of a number of pre-build shaders that have been specifically optimised for phone use Windows Phone
  • 7. Game Loop Overview Initialize Load Get User Engine Resources Input Calculate Test Criteria Give Free Resources FeedBack Windows Phone
  • 8. Game Loop Overview XNA Framework Game Loop Initialize() LoadContent() Update() Draw() UnloadContent() Windows Phone
  • 9. Creating a game world • An XNA game uses a number of variables to represent the state of the game itself – The Update method will update their values – The Draw method will produce a display that reflects their value • In the case of Cheese Roller the game must manage the texture and draw position of the cheese on the screen Windows Phone
  • 11. Windows Phone and orientation • By default a Windows Phone XNA game assumes it is running in “landscape” mode with the screen on the left of the controls • I want to change this, because I want to send the cheese down the long axis of the phone when it is rolled • I can select orientation when the game starts Windows Phone
  • 12. Orientation management • An XNA game can specify the orientations it can support • The game can bind a method to the event which is fired when the orientation changes – Games can animate the transition to the new orientation if they wish • When orientation changes the origin for the draw position is moved to the top left hand corner of the viewport • The frame of reference for accelerometer readings (of which more later) is for the phone held in Windows Phone
  • 13. Size and the scaler • An XNA game can also request a specific size of back buffer for the display • The game will be given this resolution irrespective of the actual device – The Graphics Processor (GPU) performs this scaling automatically and interpolates to remove any jagged edges • This is a great way to get performance boost by rendering to a lower resolution than the screen itself – In a fast moving game the lower resolution is not Windows noticeable Phone
  • 15. Adding Movement • 2D games are a great way to start game development • Cartesian coordinate system • Track position, direction, and speed for each object 15 Windows Phone
  • 16. Moving Objects • Vectors represent position and speed • Position Vector (10,10) – location on screen • Velocity Vector (0,10) – direction and speed Windows Phone
  • 17. Moving Objects • Vectors represent position and speed • positionVector velocityVector • Changing length of velocity vector changes speed Windows Phone
  • 18. Windows phone gesture support • For the ultimate in control you can get direct access to touch events from the panel – Up to four events can be tracked at one time – Each event is uniquely identified throughout its lifetime • However, XNA games can also use built in gesture recognition • Register an interest in a particular gesture type and then get notification when one has been performed 18 Windows Phone
  • 19. Supported gestures • The touch panel can detect a number of different gestures including – Tap – DoubleTap – Hold – HorizontalDrag, VerticalDrag and FreeDrag – Pinch – Flick • The Cheese Roller game is going to use the Flick gesture 19 Windows Phone
  • 20. Registering an interest in a gesture TouchPanel.EnabledGestures = GestureType.Flick; • The game must select those gestures that it wants to use • This can be done once at the start of the game • I do it in the XNA Initialize method • A game can also query the TouchPanel about the number of points it can track simultaneously Windows Phone
  • 22. Improving on cheese roller • The obvious improvement to Cheese Roller is to add more cheese • If we do this the physics becomes more complicated • Fortunately there are a lot of engines out there that can help • One of these is the Farseer engine • It is a 2D physics engine that is very easy to use and works well on Windows Phone • The Farseer Physics Engine is a Codeplex based project you can download from here: Windows Phone http://farseerphysics.codeplex.com/
  • 23. Using the phone accelerometer • You can also use the accelerometer to control the behavior of objects in your game • The Accelerometer can measure acceleration in X, Y and Z • You can use just the X and Y values to turn it into a replacement for a gamepad • The values that are returned are in the same range: -1 to +1 in each axis Windows Phone
  • 24. XNA Framework Accelerometer • Unlike other XNA input devices the accelerometer in XNA 4.0 is event driven • The accelerometer generates events when new readings are available • You must bind a method to the event • The method can store the settings for later use Windows Phone
  • 26. Adding sound effects • Sound effects can be added to games as additional resources • They are loaded into the Content project and provided to the game by the Content Manager Windows Phone
  • 27. Music Playback • An XNA game can also play back music files • These can be loaded from content which is part of the game assets or from the media collection on the phone • It is also possible to load the album artwork and use this in games • Music is played by the MediaPlayer object, and is not managed in the same way as sound effects Windows Phone
  • 29. XNA Framework and Fast Application Switching
  • 30. XNA Framework application switching • There is a useful MSDN document that explains how to persist and recover XNA games : http://bit.ly/soN67r Windows Phone
  • 31. Review • The Windows Phone platform provides a mix of resources that can be used to create compelling games • The Touch sensor and accelerometer inputs are easy to use in XNA programs • It is easy to add sound and music to gameplay Windows Phone
  • 32. 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. © 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.

Editor's Notes

  1. 9 XNA for Windows Phone9.1 XNA Content9.2 Game Draw/Update Behaviours9.3 Resources in XNA Games9.4 Images and Sprites9.5 Sound Effects and Background Music9.6 Touch Panel Events and Gestures9.7 Using the Accelerometer in Games9.8 Using the Motion Sensor Object in Games9.9 Using Media in Games9.10 Game Orientation and Scale9.11 Running XNA games within Silverlight Applications9.12 Fast Application Switching and Games
  2. Consistent hardware across OEMsPerformance is impressive, especially in 3DYou can use all the hardware and sensors in your Windows Phone gamesGreat tooling to facilitate game development
  3. We don’t dive in to 3D because it would take more than a session to cover it but make the point that 3D support is very impressive and easy to use relative to other 3D game development platforms.
  4. 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
  5. The Update Method is where you get user input, calculate movement, check for collisions, etc.Draw just handles rendering for the game loop cycle
  6. A game world is all the data that keeps track of game objects. Like the data in an application.
  7. Start Visual Studio Open the project CheeseRollerin the folder Demo 1 Drawing CheesePress F5 to run the program and show how the cheese is drawn top left. You may need to rotate the emulator to show this best.Stop the program and exit Visual Studio.Explain that we are now going to show how the display and orientation environment for a game can be customised.
  8. This default behaviour can be confusing, but make the point it is easy to fix.
  9. The frame of reference thing is important, it might mean that transformations are required when using the accelerometer in some games.
  10. This is a HUGE win. It means that you can fix all your asset sizes for a particular screen size and that will work on every platform, now and in the future.It also means you can get great performance hike by simply dropping the required resolution and giving the GPU less to do. Make a fuss of this, it is very useful.
  11. Start Visual Studio Open the project CheeseRollerin the folder Demo 2 Orientation and ScalePress F5 to run the program and show how the cheese is drawn top left. You may need to rotate the emulator to show this best.Stop the program and open the file CheeseRollerGame.csMove to the CheeseRollerGameconstructor.Uncomment the setup lines and re-run the program.Note that the cheese origin is now the top left hand corner in portrait mode.Stop the program.Change the back buffer size as follows:graphics.PreferredBackBufferWidth = 200;graphics.PreferredBackBufferHeight = 200;Run the program again. Note that the display is now square, with black bands. Explain that XNA will do this automatically. Ask why the cheese has not got any larger, even though the resultion is now much lower.Answer: It is because the size of the cheese is calculated from the display dimensions, so it automatically resizes for any platform.Use undo to put the source file back to the original state for next time.Save the project and then exit Visual Studio.
  12. http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.touch.gesturetype.aspx is a good place to look for these.
  13. Make the point that we can listen for a combination of gestures if we wish.
  14. Start Visual Studio Open the project CheeseRollerin the folder Demo 3 CheeseFlickPress F5 to run the program.Flick the screen and show how the cheese moves, bounces off the edges and then slows down.Make the point that this is really easy to do, and that we now have a working physics model we could use in a variety of game situations.Stop the program and open the file CheeseRollerGame.csFind the statement cheeseSpeed = gesture.Delta / 100; in the Update method.Ask what would happen if we changed the value 100 to 50.Answer: The flicks would be a lot more powerful, and would cause the cheese to move more quickly.Change the value to 50Find the statement float friction = 0.99f; Ask what would happen if we changed the 0.99 to 1.001?Answer: The game would nave negative friction, and the ball would just speed up indefinitely.Change the value to 1.001fRun the game again.Flick the cheese. Note that it goes a lot further, and slowly speeds up.Stop the program before the chees burns a hole in the side of the game.Use undo to remove the changes for next time, rebuild the application and then exit Visual Studio.Change the speed factor (100 on the previous slide) to show the effect of speeding up the game.
  15. Make the point that I have some sample games that use this that they are welcome to download.
  16. We are going to start with the standard accelerometer, which is still useful for most games.Well move onto the new Mango controls later.
  17. Make the point that normally a game would poll devices, for example gamepads, to get the user inputs to the game.
  18. Start Visual Studio Open the project CheeseRollerin the folder Demo 4 CheeseTipperPress F5 to run the program.Press the>> chevrons in the emulator to open the Additional Tools dialog.Select the Accelerometer tab in the Additional Tools dialog.Select Portrait Flat in the Orientation dropdown.Now you can tip the phone and the cheese will roll accordingly.Flick the screen and show how the cheese moves, bounces off the edges and then slows down.Make the point that this is really easy to do, and that we now have a working physics model we could use in a variety of game situations.Stop the program and open the file CheeseRollerGame.csFind the statement cheeseSpeed = gesture.Delta / 100; in the Update method.Ask what would happen if we changed the value 100 to 50.Answer: The flicks would be a lot more powerful, and would cause the cheese to move more quickly.Change the value to 50Find the statement float friction = 0.99f; Ask what would happen if we changed the 0.99 to 1.001?Answer: The game would nave negative friction, and the ball would just speed up indefinitely.Change the value to 1.001fRun the game again.Flick the cheese. Note that it goes a lot further, and slowly speeds up.Stop the program before the chees burns a hole in the side of the game.Use undo to remove the changes for next time, rebuild the application and then exit Visual Studio.Change the speed factor (100 on the previous slide) to show the effect of speeding up the game.
  19. This is the solution explorer for the cheese roller project with sound and sprites.Point out the two asset files at the bottom. Mention that these were just dragged into the project.Also make the point that we can create folders and structure the data if we have large numbers of assets.This data is automatically provided to the game when it runs.
  20. Start Visual Studio Open the project CheeseRollerin the folder Demo 5 Cheese Tipper with SoundPress F5 to run the program.Press the>> chevrons in the emulator to open the Additional Tools dialog.Select the Accelerometer tab in the Additional Tools dialog.Select Portrait Flat in the Orientation dropdown.Press F5 to run the program. Use the accelerometer emulator to make the cheese hit the edges and note that it makes a sound each timeChange the speed factor (100 on the previous slide) to show the effect of speeding up the game.
  21. This is a very complex issue that we really don’t have time to go into here.However, the document provides a good starting point.It needs to be updated so that it covers how an application knows it has been Tombstoned rather than dormant.There is a copy in this folder.