Students to Business Day 2012: Rob Miles

of 78 /78

Embed Size (px)

Transcript of Students to Business Day 2012: Rob Miles

  • 1. Initialize LoadContentUpdateDraw

2. interface ISprite{void Reset(SamplerState game);void Draw(SmudgeGame game);void Update(SmudgeGame game);} 3. Texture2D smudgeTexture = Content.Load("Smudge");smudge = new Sprite(this, smudgeTexture, Vector2.Zero,Color.Red, 20, 0); 4. public virtual void Draw(SmudgeGame game){game.spriteBatch.Draw(spriteTexture, // texture of spritespritePosition, // vector position on screennull, // source rectangle in texture (all of it)spriteColor,// colour of the lightspriteRotation, // rotation in radiansspriteOrigin, // centre of sprite position and rotationspriteScale,// scale scaled to fitSpriteEffects.None,1); // draw everything at the same depth} 5. public virtual void Draw(SmudgeGame game){game.spriteBatch.Draw(spriteTexture, // texture of spritespritePosition, // vector position on screennull, // source rectangle in texture (all of it)spriteColor,// colour of the lightspriteRotation, // rotation in radiansspriteOrigin, // centre of sprite position and rotationspriteScale,// scale scaled to fitSpriteEffects.None,1); // draw everything at the same depth} 6. public virtual void Update(SmudgeGame game){} 7. List gameSprites = new List(); 8. foreach (ISprite sprite in gameSprites)sprite.Draw(this); 9. protected override void Initialize(){TouchPanel.EnabledGestures = GestureType.Tap | GestureType.FreeDrag;base.Initialize();} 10. while (TouchPanel.IsGestureAvailable){GestureSample gesture = TouchPanel.ReadGesture();gameSprites.Add( new Sprite(this, smudgeTexture,gesture.Position, Color.Red, 20,0));} 11. Demo 1 12. class GrowingSprite : Sprite, Isprite{float spriteGrowSpeed = 0.05f;public override void Update(SmudgeGame game){spriteScale += spriteGrowSpeed;base.Update(game);}} 13. Random colorRand = new Random();Color randomColor(){int r = colorRand.Next(256);int g = colorRand.Next(256);int b = colorRand.Next(256);return Color.FromNonPremultiplied(r, g, b, 255);} 14. Demo 2 15. while (TouchPanel.IsGestureAvailable) {GestureSample gesture = TouchPanel.ReadGesture();if (gameSprites.Count > smudgesLength)gameSprites.RemoveAt(0);gameSprites.Add(new GrowingSprite(this, smudgeTexture,gesture.Position, randomColor(), 20, 0));} 16. Demo 3 17. Demo 4 18. Demo 7 19. 20. 21. 22. http://go.microsoft.com/?linkid=9730558 23. 57 24. using Microsoft.Phone.Marketplace;LicenseInformation info = new LicenseInformation();if ( info.IsTrial() ){// running in trial mode} 25. 67 26. http://www.robmiles.comTwitter @RobMiles 27. http://aka.ms/mbl-phone/starthttp://aka.ms/mbl-phone/toolshttp://aka.ms/mbl-phone/mangohttp://aka.ms/mbl-phone/register