Exemplo n.º 1
0
        //What key was pressed
        //This method fires evetytime you press button
        private void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            switch (args.VirtualKey)
            {
            //Invoke corresponding Method In GameDriver class
            case VirtualKey.Up:                                        //UP Allowed Only if Game is running
                if (_GameDriver.IsGameRunning)
                {
                    _GameDriver.MoveGoodieUp();
                }
                break;

            case VirtualKey.Down:                                     //Down Allowed Only if Game is running
                if (_GameDriver.IsGameRunning == true)
                {
                    _GameDriver.MoveGoodieDown();
                }

                break;

            case VirtualKey.Left:                                     //Left Allowed Only if Game is running
                if (_GameDriver.IsGameRunning == true)
                {
                    _GameDriver.MoveGoodieLeft();
                }
                break;

            case VirtualKey.Right:                                   // Right Allowed Only if Game is running
                if (_GameDriver.IsGameRunning == true)
                {
                    _GameDriver.MoveGoodieRight();
                }
                break;

            case VirtualKey.Space:                                   //Space Bar Allowed only if game is running
                if (_GameDriver.IsGameRunning == true)
                {
                    _GameDriver.PutGoodieAtRandomPlace();     //forgotten feature implementation
                }
                break;

            case VirtualKey.P:               //Pause Toggle On/off logic  implemented in  _GameDriver.PauseGame()method (GameDriver.cs)
                _GameDriver.PauseGame();     //New Feature
                break;
            }
        }