Esempio n. 1
0
        public TheGame(IDisplay view, Size displaySize)
        {
            _view           = view;
            _rand           = new Random();
            _allActors      = new List <Object2D>();
            _gameVars       = new GameVars();
            _bGameIsRunning = false;
            _displaySize    = displaySize;

            SetUpGame();
        }
Esempio n. 2
0
        public void KeyHandler(Keys key, KeyState state)
        {
            GameVars gameVars = _stageController.GetGameVars();

            //////////////
            // PLAYER 1 //
            //////////////
            if (key == gameVars.PLAYER1_START)
            {
                if (_player1 != null)
                {
                    _player1.Start(state);
                }
            }
            else if (key == gameVars.PLAYER1_UP)
            {
                if (_player1 != null)
                {
                    _player1.Up(state);
                }
            }
            else if (key == gameVars.PLAYER1_DOWN)
            {
                if (_player1 != null)
                {
                    _player1.Down(state);
                }
            }
            else if (key == gameVars.PLAYER1_LEFT)
            {
                if (_player1 != null)
                {
                    _player1.Left(state);
                }
            }
            else if (key == gameVars.PLAYER1_RIGHT)
            {
                if (_player1 != null)
                {
                    _player1.Right(state);
                }
            }
            else if (key == gameVars.PLAYER1_BUTTON1)
            {
                if (_player1 != null)
                {
                    _player1.Button1(state);
                }
            }
            else if (key == gameVars.PLAYER1_BUTTON2)
            {
                if (_player1 != null)
                {
                    _player1.Button2(state);
                }
            }
            //////////////
            // PLAYER 2 //
            //////////////
            else if (key == gameVars.PLAYER2_START)
            {
                if (_player2 != null)
                {
                    _player2.Start(state);
                }
            }
            else if (key == gameVars.PLAYER2_UP)
            {
                if (_player2 != null)
                {
                    _player2.Up(state);
                }
            }
            else if (key == gameVars.PLAYER2_DOWN)
            {
                if (_player2 != null)
                {
                    _player2.Down(state);
                }
            }
            else if (key == gameVars.PLAYER2_LEFT)
            {
                if (_player2 != null)
                {
                    _player2.Left(state);
                }
            }
            else if (key == gameVars.PLAYER2_RIGHT)
            {
                if (_player2 != null)
                {
                    _player2.Right(state);
                }
            }
            else if (key == gameVars.PLAYER2_BUTTON1)
            {
                if (_player2 != null)
                {
                    _player2.Button1(state);
                }
            }
            else if (key == gameVars.PLAYER2_BUTTON2)
            {
                if (_player2 != null)
                {
                    _player2.Button2(state);
                }
            }
            ///////////
            // OTHER //
            ///////////
            else if (key == gameVars.QUIT)
            {
                _stageController.Exit();
            }
        }