예제 #1
0
        private void mainWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (MefShapesGame.IsRunning)
            {
                switch (e.Key)
                {
                case Key.Right:
                    MefShapesGame.ActiveShape.Move(Direction.Right);
                    break;

                case Key.Left:
                    MefShapesGame.ActiveShape.Move(Direction.Left);
                    break;

                case Key.Down:
                    MefShapesGame.ActiveShape.Move(Direction.Down);
                    break;

                case Key.Up:
                    MefShapesGame.ActiveShape.Move(Direction.Up);
                    break;

                case Key.Space:
                    MefShapesGame.ActiveShape.Rotate(Direction.Right);
                    break;

                case Key.Return:
                    MefShapesGame.StopGame();
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (e.Key == Key.Return || e.Key == Key.Space)
                {
                    MefShapesGame.StartGame(this.Dispatcher, 300);
                }
            }
        }
예제 #2
0
 public MainWindow()
 {
     InitializeComponent();
     this.Loaded += delegate { MefShapesGame.StartGame(this.Dispatcher, 300); };
 }