public void Update(float delta)
        {
            _fade?.MoveNext();

            delta *= _scrollingSpeed;

            _offsetPosHills1 += delta * 25;
            _offsetPosHills2 += delta * 20;
            _offsetPosStars  += delta * 10;
            _offsetPosMoon   += delta * 9;

            float plrPos = Maths.InverseLerp(Player.MIN_Y, Player.MAX_Y, Program.Player.Position.y);

            _yPosHills1 = Maths.Lerp(11, 4, plrPos);
            _yPosHills2 = Maths.Lerp(7, 1, plrPos);
            _yPosStars  = Maths.Lerp(-5, -20, plrPos);

            if (_offsetPosHills1 >= SIZE_HILL)
            {
                _offsetPosHills1 -= SIZE_HILL;
            }

            if (_offsetPosHills2 >= SIZE_HILL)
            {
                _offsetPosHills2 -= SIZE_HILL;
            }

            if (_offsetPosStars >= SIZE_HILL)
            {
                _offsetPosStars -= SIZE_HILL;
            }

            if (_offsetPosMoon >= 200)
            {
                _offsetPosMoon -= 200;
            }

            for (int i = 0; i < BG_COUNT; i++)
            {
                float rel = -SIZE_HILL + i * SIZE_HILL;

                _hills1[i].SetPosition(new Vector2(rel - _offsetPosHills1, _yPosHills1));
                _hills2[i].SetPosition(new Vector2(rel - _offsetPosHills2 + _offset2, _yPosHills2));
                _stars[i].SetPosition(new Vector2(rel - _offsetPosStars, _yPosStars));

                if (i == 0)
                {
                    _moon[i].Spawn(new Vector2(90 - _offsetPosMoon, _yPosStars - 12), Vector2.zero);
                }
            }
        }
Exemple #2
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            if (_isDying)
            {
                return;
            }
            if (followPlayer)
            {
                float plrPos = Maths.InverseLerp(Player.MIN_Y, Player.MAX_Y, Program.Player.Position.y);
                Position = Vector2.SmoothDamp(Position, new Vector2(55, Maths.Lerp(-6, 6, plrPos)), ref _velocity, _smoothTime, deltaTime);
            }

            Player.MAX_X = CanCollide ? Position.x - 20.0f : 77;
            UpdateLasers(deltaTime);
        }