Пример #1
0
        //public Point point1 { get; set; }
        //public Point point2 { get; set; }

        //public Rect rect { get; set; }

        public MainPage()
        {
            this.InitializeComponent();
            mainMenu = new MainMenu();
            game     = new Asteroids_Game(1400, 760);
            Window.Current.CoreWindow.KeyDown += OnKeyDown;
            Window.Current.CoreWindow.KeyUp   += OnKeyUp;
            //point1 = new Point(0, 0);
            //point2 = new Point(1100, 1100);
            //rect = new Rect(point1, point2);
        }
Пример #2
0
 private void OnKeyUp(CoreWindow sender, KeyEventArgs args)
 {
     if (args.VirtualKey == Windows.System.VirtualKey.W || args.VirtualKey == Windows.System.VirtualKey.Up)
     {
         game.IsUpButtonPressed = false;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.S || args.VirtualKey == Windows.System.VirtualKey.Down)
     {
         game.IsDownButtonPressed = false;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.A || args.VirtualKey == Windows.System.VirtualKey.Left)
     {
         game.IsLeftButtonPressed = false;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.D || args.VirtualKey == Windows.System.VirtualKey.Right)
     {
         game.IsRightButtonPressed = false;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.Space)
     {
         game.IsSpaceBarPressed = false;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.Y && game.gameOver == true)
     {
         game = new Asteroids_Game(1400, 760);
         Window.Current.CoreWindow.KeyDown += OnKeyDown;
         Window.Current.CoreWindow.KeyUp   += OnKeyUp;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.N && game.gameOver == true)
     {
         mainMenu = new MainMenu();
     }
     if (args.VirtualKey == Windows.System.VirtualKey.Number1 && mainMenu.gameStarted == false)
     {
         mainMenu.gameStarted = true;
         game = new Asteroids_Game(1400, 760);
         Window.Current.CoreWindow.KeyDown += OnKeyDown;
         Window.Current.CoreWindow.KeyUp   += OnKeyUp;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.Number2 && mainMenu.gameStarted == false)
     {
         mainMenu.onInstructions = true;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.Number3 && mainMenu.gameStarted == false)
     {
         mainMenu.onCredits = true;
     }
     if (args.VirtualKey == Windows.System.VirtualKey.B && mainMenu.gameStarted == false)
     {
         mainMenu.onInstructions = false;
         mainMenu.onCredits      = false;
     }
 }