Exemple #1
0
        /// <summary>
        /// This method is to run updates only necessary to Windows.
        /// The features inside this method provide camera zooming -
        /// ('O' to increase, 'P' to decrease)
        ///
        /// To allow the click and drag capability for the right
        /// button on the mouse so that the user can manipulate
        /// their direction of gravity based on their desired dragging direction.
        ///
        /// The method also updates the mouse position but modified
        /// with the consideration of zooming of the camera to provide
        /// effective placement
        /// </summary>
        /// <param name="a_gameTime"></param>
        private void WindowsUpdate(GameTime a_gameTime)
        {
            //Zooming features
            if (Keyboard.GetState().IsKeyDown(Keys.O))
            {
                m_camera.Zoom += 0.01f;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {
                m_camera.Zoom -= 0.01f;
            }

            //Enabling 'click n drag' for gravity on PC
            ButtonState rmb = Mouse.GetState().RightButton;

            if (!m_mouseDragging && rmb == ButtonState.Pressed && m_gravCanChange)
            {
                m_mouseDragging = true;
                m_gravityBegin  = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
            }
            else if (m_mouseDragging && rmb == ButtonState.Released && m_gravCanChange)
            {
                if (m_gravityBegin != new Vector2(Mouse.GetState().X, Mouse.GetState().Y))
                {
                    m_mouseDragging = false;
                    Vector2 gravityDirection = (new Vector2(Mouse.GetState().X, Mouse.GetState().Y)) - m_gravityBegin;
                    m_gravity.direction = gravityDirection;
                }
            }

            //Scaling mousePosition with consideration of camera zooming
            m_mousePos = (new Vector2(Mouse.GetState().X, Mouse.GetState().Y) -
                          new Vector2(m_windowRes.Width / 2, m_windowRes.Height / 2))
                         * (1 / m_camera.Zoom)
                         + m_camera.Position;

            //HotKeys
            if (Keyboard.GetState().IsKeyDown(Keys.Y))
            {
                m_gameStateManager.PopState();
                m_gameStateManager.PushState("editor");
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (m_currentLevel != "Pause")
                {
                    m_gameStateManager.PushState("pause");
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.IsMouseVisible = true;

            ContentLibrary.LoadContentLibrary(Content);

            m_scoreList = new List <Score>();
            m_scoreList = LevelIO.LoadScore("scores.bin");

            //GameState Manager Stuff
            m_gameStateManager = new GameStateManager(this);

            PlayingGameState m_playingGameState =
                new PlayingGameState(m_gameStateManager, windowRes);

            LevelEditor m_editor =
                new LevelEditor(m_gameStateManager, windowRes);

            SplashScreen m_splash =
                new SplashScreen(m_gameStateManager, windowRes);

            MenuGameState m_menu =
                new MenuGameState(m_gameStateManager, windowRes);

            PauseGameState m_pause =
                new PauseGameState(m_gameStateManager, windowRes);

            TutorialGameState m_tutorial =
                new TutorialGameState(m_gameStateManager, windowRes);

            Level1GameState m_level1 =
                new Level1GameState(m_gameStateManager, windowRes);

            Level2GameState m_level2 =
                new Level2GameState(m_gameStateManager, windowRes);

            Level3GameState m_level3 =
                new Level3GameState(m_gameStateManager, windowRes);

            m_gameStateManager.SetState("playingGS", m_playingGameState);
            m_gameStateManager.SetState("editor", m_editor);
            m_gameStateManager.SetState("splashScreen", m_splash);
            m_gameStateManager.SetState("menu", m_menu);
            m_gameStateManager.SetState("pause", m_pause);
            m_gameStateManager.SetState("tutorial", m_tutorial);
            m_gameStateManager.SetState("level1", m_level1);
            m_gameStateManager.SetState("level2", m_level2);
            m_gameStateManager.SetState("level3", m_level3);

            m_gameStateManager.PushState("splashScreen");
            base.Initialize();

            for (int i = 0; i < m_scoreList.Count; i++)
            {
                Console.WriteLine(m_scoreList[i].m_level);
                Console.WriteLine(m_scoreList[i].m_time);
                Console.WriteLine(m_scoreList[i].m_deaths);
            }
        }
Exemple #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.IsMouseVisible = true;

            ContentLibrary.LoadContentLibrary(Content);

            m_scoreList = new List<Score>();
            m_scoreList = LevelIO.LoadScore("scores.bin");

            //GameState Manager Stuff
            m_gameStateManager = new GameStateManager(this);
            
            PlayingGameState m_playingGameState =
                new PlayingGameState(m_gameStateManager, windowRes);
            
            LevelEditor m_editor =
                new LevelEditor(m_gameStateManager, windowRes);

            SplashScreen m_splash =
                new SplashScreen(m_gameStateManager, windowRes);

            MenuGameState m_menu =
                new MenuGameState(m_gameStateManager, windowRes);

            PauseGameState m_pause =
                new PauseGameState(m_gameStateManager, windowRes);

            TutorialGameState m_tutorial =
                new TutorialGameState(m_gameStateManager, windowRes);

            Level1GameState m_level1 =
                new Level1GameState(m_gameStateManager, windowRes);

            Level2GameState m_level2 =
                new Level2GameState(m_gameStateManager, windowRes);

            Level3GameState m_level3 =
                new Level3GameState(m_gameStateManager, windowRes);

            m_gameStateManager.SetState("playingGS", m_playingGameState);
            m_gameStateManager.SetState("editor", m_editor);
            m_gameStateManager.SetState("splashScreen", m_splash);
            m_gameStateManager.SetState("menu", m_menu);
            m_gameStateManager.SetState("pause", m_pause);
            m_gameStateManager.SetState("tutorial", m_tutorial);
            m_gameStateManager.SetState("level1", m_level1);
            m_gameStateManager.SetState("level2", m_level2);
            m_gameStateManager.SetState("level3", m_level3);

            m_gameStateManager.PushState("splashScreen");
            base.Initialize();

            for (int i = 0; i < m_scoreList.Count; i++)
            {
                Console.WriteLine(m_scoreList[i].m_level);
                Console.WriteLine(m_scoreList[i].m_time);
                Console.WriteLine(m_scoreList[i].m_deaths);
            }
        }