示例#1
0
 public void Update(double elapsed, Chicken chicken, out bool collidesWithChicken)
 {
     Position.Y += Speed * (float)elapsed;
     if (Position.Y + Size.Y > chicken.Position.Y)
     {
         Rectangle c1 = this.CollisionRect;
         c1.Offset((int)Position.X, (int)Position.Y);
         Rectangle c2 = chicken.CollisionRect;
         c2.Offset((int)chicken.Position.X, (int)chicken.Position.Y);
         collidesWithChicken = c1.Intersects(c2);
     }
     else
     {
         collidesWithChicken = false;
     }
 }
示例#2
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen = true;
            Content.RootDirectory = "Content";

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

#if !NETFX_CORE
            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);
#endif

            dog = new Dog();
            dog.DropEgg += dog_DropEgg;
            dog.Position = new Vector2(400 - dog.Center.X, 50);
            chicken = new Chicken();
            chicken.Position = new Vector2(400 - chicken.Center.X, 330);
            rand = new Random();
        }