Example #1
0
        public void Update(float elapsed)
        {
            player.Update(elapsed);
            foreach (Block block in blocks)
            {
                block.Collide(player);
            }

            camera.Update(player.Position);

            foreach (Light1 light in lights)
            {
                light.Update(elapsed);
            }
        }
Example #2
0
        public void Update(float elapsed)
        {
            player.Update(elapsed);

            foreach (IObstacle obstacle in obstacles)
            {
                obstacle.Collide(player);
            }

            camera.Update(player);

            foreach (Light light in lights)
            {
                light.Update(elapsed);
            }
        }
Example #3
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            foreach (var component in levelUpdateComponenet)
            {
                component.Update(gameTime);
            }

            _camera.Update(gameTime, ref _player.Shell);

            base.Update(gameTime);
        }
Example #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // The active state from the last frame is now old
            lastMouseState = currentMouseState;

            // Get the mouse state relevant for this frame
            currentMouseState = Mouse.GetState();

            // Recognize a single click of the left mouse button
            if (isDebugMode && lastMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed)
            {
                timesClicked++;
                //positions.WriteLine("EntityManager.Add(new Hitbox(world, new Vector2(" + debugBox.Position.X + ", " + debugBox.Position.Y + "), new Vector2(" + debugBox.wi + ", " + debugBox.h + ")));");
                //positions.WriteLine("EntityManager.Add(new Hitbox(world, new Vector2(" + debugBox.Position.X + "f, " + debugBox.Position.Y + "f), new Vector2(" + debugBox.wi + ", " + debugBox.h +")));");
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here

            base.Update(gameTime);

            if (Keyboard.GetState().IsKeyDown(Keys.R) && isDebugMode)
            {
                LevelManager.ReloadLevel();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.N) && GameRoot.isDebugMode)
            {
                LevelManager.LoadNextLevel();
            }


            // in Update()
            EntityManager.Update();
            LevelManager.Update();
            SFX.Update();
            camera.Update();

            world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
        }
Example #5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardState state     = Keyboard.GetState();
            var           padState  = GamePad.GetState(PlayerIndex.One);
            var           collision = new Collision(_tileArray);
            var           colCheck  = collision.CheckCollision(_player, _world);

            _tileArray = _world._activeRoom;
            var playerMoving = _player.Input(state, padState, colCheck);

            // TODO: Add your update logic here
            _world.WorldUpdate();
            score++;
            if (playerMoving)
            {
                _player.animatedSprite.Update();
            }
            if (_itemDrop != null)
            {
                _itemDrop.animatedSprite.Update();
            }
            //_enemy.animatedSprite.Update();
            base.Update(gameTime);

            //var inDistance = checkDistance(_enemy.position, _player.position);
            //_enemy.Walk(_player.position, inDistance);
            if (_itemDrop != null)
            {
                var inDistance = checkDistance(_itemDrop.position, _player.position);
                var pickUp     = _itemDrop.PickUp(_player, inDistance);
                if (pickUp)
                {
                    _itemDrop = null;
                }
            }

            _camera.Update(_player.position);
        }