Beispiel #1
0
        public override void UpdateCore(GameRound round, float elapsedSeconds)
        {
            base.UpdateCore(round, elapsedSeconds);

            if (!IsStunned || !round.ObjectsIn(new Box(Position, GroundArea)).OfType <Block>().Any())
            {
                Position += new Vector2((Direction == Direction.Left ? -1 : +1) * speed * elapsedSeconds, 0);
            }
        }
        public override void UpdateCore(GameRound round, float elapsedSeconds)
        {
            base.UpdateCore(round, elapsedSeconds);

            controls.Update(elapsedSeconds);
            Position += new Vector2(controls.HorizontalSpeed * 20f, 0) * elapsedSeconds;
            if (controls.HorizontalSpeed > 0)
            {
                Direction = true;
            }
            if (controls.HorizontalSpeed < 0)
            {
                Direction = false;
            }
            if (controls.IsAttemptingToJump)
            {
                if (round.ObjectsIn(new Box(Position, JumpArea)).Any())
                {
                    Velocity = new Vector2(Velocity.X, 30);
                }
            }
        }