KEMBAR78
Md2010 jl-wp7-sl-game-dev | PPTX
Developing WP7 Appswith SilverlightJosé Luis LatorreMicrosoft MVP, UX Specialist & Brainsiders CEOhttp://silverlightguy.com
Generalni sponzori:Organizatori:Glavni sponzori:Generalni medijski sponzor:Sponzori:Medijski sponzori:Strateški partneri:Službena PR agencija:
Gameswith Silverlight? Why?
Silverlight is for games?Concretely, Silverlight isgood for casual gamesthatdoesn’trequireintensivegraphiccapabilities. Wehavethefactthat:Playerslove casual games (simple & easyto pick up and putdown).Phone platforms are great for thisSilverlight isgreat for this.
Why Silverlight  Compelling Cross-Platform User ExperienceFlexible object-oriented modelFully managed code to improve encapsulation and centralizationDeclarative presentation language (Xaml)Role specific toolsRapid application development Good performance
Whatkind of games?Word gamesDesk gamesTurn based strategy gamesPictorial gamesPlatform gamesTouch interaction gamesIf this is what you want to write there might be no need to learn XNA..
The Game Loop
Game Loop IThe “GAME LOOP”
 Executes once per frame
 It handles all the game logic, animation, Collisions, manages input, applies game logic, etc.
 Optimal game loop in Silverlight is usually implemented with CompositionTarget.Rendering, which executes once per rendered frame.
Final Hardware will execute 30 Frames Per Second
For details on deciding the Game Loop implementation, check http://nokola.com/ and its ”GameLoopsInSilverlight.docx” document. Game Loop IIIs the ”Heart Beat” of the game...Typical game loop logicChecks for user inputChecks for collisionsUpdates all the game elements visualsDraws all game elements (Actually not needed in Silverlight due to the Visual Tree Model)Applies Game logic & AI.
Game loop IIIprotectedDateTimelastTick;    public Page(){InitializeComponent();CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);lastTick = DateTime.Now;}void CompositionTarget_Rendering(object sender, EventArgs e){DateTimenow = DateTime.Now;TimeSpanelapsed = now - lastTick;lastTick = now;    //Game Logicgoeshere}
SpritesThe game characters can be represented by Sprites, which are usually represented by an image and a position on the game surface.So they have:Image.Position.Vector of movement.Other details, depending on the game.
Animated SpritesAn animated sprite is the natural evolution as it can show an animation instead of a still image, which is good if the player is walking, to show a walking animation. So they have, additionally from the Sprite:An animation or sequence of images, also called Frames.Speed of the animation ( frames per second)Number of Frames.
Game characterA game character derives from a sprite or animated sprite and represents a game element, the player, an enemy, bonus, obstacle, etc..It usually has its own logic and is tied to events that determine its behavior.
Sprite, Camera, Action(link to demo)Note: This demo isderivedfrom a samplefrom Andy Bealieu.
Collisions IIf two sprites (or animated sprites) collide, for example the player and a enemy, something must happen!!For this, we must know if there is a collision between both sprites.Usually a calculation of the bounding boxes will be enough.
Collisions IIFirst, we need the bounding boxes of the two elements we want to discover if they have collided:public static RectUserControlBounds(FrameworkElement control){Point ptTopLeft = new Point(Convert.ToDouble(control.GetValue(Canvas.LeftProperty)), Convert.ToDouble(control.GetValue(Canvas.TopProperty)));Point ptBottomRight = new Point(Convert.ToDouble(control.GetValue(Canvas.LeftProperty)) + control.Width, Convert.ToDouble(control.GetValue(Canvas.TopProperty)) + control.Height);returnnew Rect(ptTopLeft, ptBottomRight);}
Collisions IIINext we validate if both bounding boxes overlap each other:public static boolRectIntersect(Rectangle rectangle1, Rectangle rectangle2){return (((double)rectangle1.GetValue(Canvas.LeftProperty) <= (double)rectangle2.GetValue(Canvas.LeftProperty) + rectangle2.Width)        && ((double)rectangle1.GetValue(Canvas.LeftProperty) + rectangle1.Width >= (double)rectangle2.GetValue(Canvas.LeftProperty))        && ((double)rectangle1.GetValue(Canvas.TopProperty) <= (double)rectangle2.GetValue(Canvas.TopProperty) + rectangle2.Height)        && ((double)rectangle1.GetValue(Canvas.TopProperty) + rectangle1.Height >= (double)rectangle2.GetValue(Canvas.TopProperty)));}
Input
Input via ButtonsBack – Start – Search OnlyNOT usable for Games!
Input via TouchUIElement Class contains Events
ManipulationStarted
ManipulationDelta
ManipulationCompleted
Supported in Emulator
Requires Multitouch MonitorInput via Accelerometer+Y1Measures force applied on each axis over timeNot supported by Emulator
 Can be faked using Mouse Input + Perspective Transform-Z-X+X+Z-Y
Alltogethernow!! – A shootinggame(link to demo)Note: This demo isderivedfroma greatsamplefromMatthew Casperson.
Otherpoints
Performance Statistics Set EnableFrameRateCounter = trueA – Render Thread FramerateB – UI Thread FramerateC – Amount of Video Memory UsedD – Total # of Textures UsedE – Total # of Intermediate Textures UsedSet EnableCacheVisualization = true
Tinted items are NOT being cached by GPUAutomatic GPU Acceleration Automatically Applied to
StoryBoardAnimations

Md2010 jl-wp7-sl-game-dev

  • 2.
    Developing WP7 AppswithSilverlightJosé Luis LatorreMicrosoft MVP, UX Specialist & Brainsiders CEOhttp://silverlightguy.com
  • 4.
    Generalni sponzori:Organizatori:Glavni sponzori:Generalnimedijski sponzor:Sponzori:Medijski sponzori:Strateški partneri:Službena PR agencija:
  • 5.
  • 6.
    Silverlight is forgames?Concretely, Silverlight isgood for casual gamesthatdoesn’trequireintensivegraphiccapabilities. Wehavethefactthat:Playerslove casual games (simple & easyto pick up and putdown).Phone platforms are great for thisSilverlight isgreat for this.
  • 7.
    Why Silverlight Compelling Cross-Platform User ExperienceFlexible object-oriented modelFully managed code to improve encapsulation and centralizationDeclarative presentation language (Xaml)Role specific toolsRapid application development Good performance
  • 8.
    Whatkind of games?WordgamesDesk gamesTurn based strategy gamesPictorial gamesPlatform gamesTouch interaction gamesIf this is what you want to write there might be no need to learn XNA..
  • 9.
  • 10.
    Game Loop IThe“GAME LOOP”
  • 11.
  • 12.
    It handlesall the game logic, animation, Collisions, manages input, applies game logic, etc.
  • 13.
    Optimal gameloop in Silverlight is usually implemented with CompositionTarget.Rendering, which executes once per rendered frame.
  • 14.
    Final Hardware willexecute 30 Frames Per Second
  • 15.
    For details ondeciding the Game Loop implementation, check http://nokola.com/ and its ”GameLoopsInSilverlight.docx” document. Game Loop IIIs the ”Heart Beat” of the game...Typical game loop logicChecks for user inputChecks for collisionsUpdates all the game elements visualsDraws all game elements (Actually not needed in Silverlight due to the Visual Tree Model)Applies Game logic & AI.
  • 16.
    Game loop IIIprotectedDateTimelastTick; public Page(){InitializeComponent();CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);lastTick = DateTime.Now;}void CompositionTarget_Rendering(object sender, EventArgs e){DateTimenow = DateTime.Now;TimeSpanelapsed = now - lastTick;lastTick = now; //Game Logicgoeshere}
  • 17.
    SpritesThe game characterscan be represented by Sprites, which are usually represented by an image and a position on the game surface.So they have:Image.Position.Vector of movement.Other details, depending on the game.
  • 18.
    Animated SpritesAn animatedsprite is the natural evolution as it can show an animation instead of a still image, which is good if the player is walking, to show a walking animation. So they have, additionally from the Sprite:An animation or sequence of images, also called Frames.Speed of the animation ( frames per second)Number of Frames.
  • 19.
    Game characterA gamecharacter derives from a sprite or animated sprite and represents a game element, the player, an enemy, bonus, obstacle, etc..It usually has its own logic and is tied to events that determine its behavior.
  • 20.
    Sprite, Camera, Action(linkto demo)Note: This demo isderivedfrom a samplefrom Andy Bealieu.
  • 21.
    Collisions IIf twosprites (or animated sprites) collide, for example the player and a enemy, something must happen!!For this, we must know if there is a collision between both sprites.Usually a calculation of the bounding boxes will be enough.
  • 22.
    Collisions IIFirst, weneed the bounding boxes of the two elements we want to discover if they have collided:public static RectUserControlBounds(FrameworkElement control){Point ptTopLeft = new Point(Convert.ToDouble(control.GetValue(Canvas.LeftProperty)), Convert.ToDouble(control.GetValue(Canvas.TopProperty)));Point ptBottomRight = new Point(Convert.ToDouble(control.GetValue(Canvas.LeftProperty)) + control.Width, Convert.ToDouble(control.GetValue(Canvas.TopProperty)) + control.Height);returnnew Rect(ptTopLeft, ptBottomRight);}
  • 23.
    Collisions IIINext wevalidate if both bounding boxes overlap each other:public static boolRectIntersect(Rectangle rectangle1, Rectangle rectangle2){return (((double)rectangle1.GetValue(Canvas.LeftProperty) <= (double)rectangle2.GetValue(Canvas.LeftProperty) + rectangle2.Width) && ((double)rectangle1.GetValue(Canvas.LeftProperty) + rectangle1.Width >= (double)rectangle2.GetValue(Canvas.LeftProperty)) && ((double)rectangle1.GetValue(Canvas.TopProperty) <= (double)rectangle2.GetValue(Canvas.TopProperty) + rectangle2.Height) && ((double)rectangle1.GetValue(Canvas.TopProperty) + rectangle1.Height >= (double)rectangle2.GetValue(Canvas.TopProperty)));}
  • 24.
  • 25.
    Input via ButtonsBack– Start – Search OnlyNOT usable for Games!
  • 26.
    Input via TouchUIElementClass contains Events
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
    Requires Multitouch MonitorInputvia Accelerometer+Y1Measures force applied on each axis over timeNot supported by Emulator
  • 32.
    Can befaked using Mouse Input + Perspective Transform-Z-X+X+Z-Y
  • 33.
    Alltogethernow!! – Ashootinggame(link to demo)Note: This demo isderivedfroma greatsamplefromMatthew Casperson.
  • 34.
  • 35.
    Performance Statistics SetEnableFrameRateCounter = trueA – Render Thread FramerateB – UI Thread FramerateC – Amount of Video Memory UsedD – Total # of Textures UsedE – Total # of Intermediate Textures UsedSet EnableCacheVisualization = true
  • 36.
    Tinted items areNOT being cached by GPUAutomatic GPU Acceleration Automatically Applied to
  • 37.
  • 38.
    Perspective 3D(PlaneProjections) – but only if they are applied by Storyboard animations.
  • 39.
    Uses VideoCard for Transform, Rotate, Scale, Rectangular Clip
  • 40.
    NOT automaticfor Procedural Animation!monetization
  • 41.
  • 42.
    MonetizationTry and buyDetailedproduct descriptionScreen shotsReviews & ratingsRelated appsOptional game content ratingMore apps by developer
  • 43.
    Monetization70% revenue shareTrialAPICredit card & mobile operator billingPaid, ad funded and free apps
  • 44.
    Deployment ProcessDevelop &DebugSubmit& ValidateCertify & SignWindows Phone Application Deployment ServiceMarketplace
  • 45.
  • 46.
  • 47.
    Cool games, samples& tutshttp://silverarcade.com/games/InnoveWare/quakelighthttp://dobbschallenge2.com/http://silverarcade.com/games/ddtmm/vsahttp://www.mashooo.com/SilverlightGames/Tire_Storm.aspxhttp://dl.dropbox.com/u/2681028/CodeplexData/WriteableBitmapEx/BlitSample/TestPage.htmlhttp://www.brighthub.com/internet/web-development/articles/14494.aspx
  • 49.

Editor's Notes