Esempio n. 1
0
 public override void Update(GameTime gametime)
 {
     if (ButtonStart.IsClicked())
     {
         PublicMember.CurrentScreen = PublicMember.ChangeScreen(Screens.PlayScreen);
     }
     if (ButtonExit.IsClicked())
     {
         Process.GetCurrentProcess().Kill();
     }
     base.Update(gametime);
 }
Esempio n. 2
0
 public override void Update(GameTime gametime)
 {
     Frog.Position.X = MathHelper.Clamp(Frog.Position.X, Frog.Width() / 2, Game1.ScreenWidth - Frog.Width() / 2);
     Frog.Position.Y = MathHelper.Clamp(Frog.Position.Y, Frog.Height() / 2, Game1.ScreenHeight - Frog.Height() / 2);
     if (Keyboard.GetState().IsKeyDown(Keys.Escape))
     {
         PublicMember.CurrentScreen = PublicMember.ChangeScreen(Screens.MenuScreen);
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Left))
     {
         Frog.Direction   = SpriteEffects.None;
         Frog.Position.X -= 6;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Right))
     {
         Frog.Direction   = SpriteEffects.FlipHorizontally;
         Frog.Position.X += 6;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.D))
     {
         Bear.Direction = SpriteEffects.FlipHorizontally;
     }
     if (gametime.TotalGameTime.TotalMilliseconds >= TimeForSecond + 1000)
     {
         TimeForSecond = gametime.TotalGameTime.TotalMilliseconds;
         Second second = new Second();
         second.Initialize(SecondTexture, new Vector2()
         {
             X = Game1.ran.Next(0, Game1.ScreenWidth - 10),
             Y = 0
         });
         Seconds.Add(second);
     }
     if (Seconds.Count > 0)
     {
         for (int i = Seconds.Count - 1; i >= 0; i--)
         {
             Seconds[i].Position.Y += 3;
             if (Seconds[i].Position.Y >= Game1.ScreenHeight - Seconds[i].Height() / 2 || Seconds[i].Rectangle.Intersects(Frog.Rectangle))
             {
                 Seconds.Remove(Seconds[i]);
             }
         }
     }
     base.Update(gametime);
 }