示例#1
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Space)
     {
         if (!Game.IsActive)
         {
             Game.Start();
         }
         else if (!Game.IsPaused)
         {
             Game.Floor();
         }
     }
     else if (e.Key == Key.P)
     {
         Game.Pause();
     }
     else if (Game.IsPaused || !Game.IsActive)
     {
         return;
     }
     else if (e.Key == Key.S)
     {
         Game.Drop();
     }
     else if (e.Key == Key.W)
     {
         Game.Rotate();
     }
     else if (e.Key == Key.A || e.Key == Key.Left)
     {
         Game.LeftDown = true;
         if (Game.MovingDirection != 1)
         {
             Game.MovingDirection = -1;
         }
     }
     else if (e.Key == Key.D || e.Key == Key.Right)
     {
         Game.RightDown = true;
         if (Game.MovingDirection != -1)
         {
             Game.MovingDirection = 1;
         }
     }
 }