// Walk horizontaly
        public override void WalkHorizontal(float targetSpeed)
        {
            // lerp the sprite scale (prob wont keep)
            imageScale = MyMaths.Lerp(imageScale,
                                      Math.Sign(targetSpeed),
                                      .25f * GahameController.GameSpeed * (GameInput.ControllerMode && !GahameController.CutScene ? Math.Abs(GameInput.AbsLeftStickX) : 1));

            // keeps it from memeing maxSpeed
            targetSpeed = MyMaths.Clamp(targetSpeed, -maxSpeed, maxSpeed);

            // Approach the target speed
            physics.Velocity.X = MyMaths.Approach(physics.Velocity.X, targetSpeed,
                                                  GahameController.GameSpeed * (physics.Grounded ? accelerationSpeed : airAccelerationSpeed));

            // Sprite things
            if (spriteManager.CurrentSprite != "Moving")
            {
                spriteManager.ChangeSprite("Moving");
                spriteManager.GetSprite("Moving").CurrentImage = 0;
            }
            spriteManager.GetSprite("Moving").ImageSpeed = .1f * Math.Abs(physics.Velocity.X / maxSpeed);

            // You be walking
            WalkingHorizontal = true;
        }
示例#2
0
        // Walk vertically
        public override void WalkVertical(float speed)
        {
            // Approach the speed
            physics.Velocity.Y = MyMaths.Approach(physics.Velocity.Y, speed, accelerationSpeed * GahameController.GameSpeed);
            WalkingVertical    = true;

            direction.X = 0;
            direction.Y = Math.Sign(speed);
        }
示例#3
0
 // Update
 public override void Update(GameTime gameTime)
 {
     // do the fade stuff
     alpha = MyMaths.Approach(alpha, (reverseAlpha ? 0 : 1), fadeSpeed);
     if (alpha >= 1)
     {
         reverseAlpha = true;
         ChangeScreen();
     }
     if (alpha == 0)
     {
         StopTransition();
     }
 }
示例#4
0
        // Updateroni
        public override void Update(GameTime gameTime)
        {
            // Inportant fix
            size  = new Vector2(Camera.View.X, Camera.View.Y / 4);
            size2 = new Vector2(Camera.View.X / 2, Camera.View.Y);

            // Y Position fix
            rec1.Y = 0;
            rec2.Y = size.Y;
            rec3.Y = size.Y * 2;
            rec4.Y = size.Y * 3;

            // rec 1 thing
            speed1 = MyMaths.Approach(speed1, 1, 0.95f);
            rec1.X = MyMaths.Approach(rec1.X, 0, speed1);

            // rec 2 thing
            if (rec1.X == 0)
            {
                speed4 = MyMaths.Approach(speed4, 1, 0.95f);
                rec4.X = MyMaths.Approach(rec4.X, 0, speed4);
            }

            // rec 3 and 4 ok
            if (rec4.X == 0)
            {
                speed2 = MyMaths.Approach(speed2, 1, 0.95f);
                rec2.X = MyMaths.Approach(rec2.X, 0, speed2);
                rec3.X = MyMaths.Approach(rec3.X, 0, speed2);
            }

            // rec 5 n 6
            if (rec2.X == 0)
            {
                if (!screenChanged)
                {
                    ChangeScreen();
                    screenChanged = true;
                }
                rec5.X = MyMaths.Approach(rec5.X, -size2.X, 5);
                rec6.X = MyMaths.Approach(rec6.X, size.X, 5);
            }

            // STOPIT
            if (rec6.X == size.X)
            {
                StopTransition();
            }
        }
示例#5
0
文件: Music.cs 项目: zazati99/Gahame
        // Fade Track
        public void FadeTrack(string trackName, float newVolume, float fadeSpeed)
        {
            SoundEffectInstance tempSound = Tracks[trackName];

            tempSound.Volume = MyMaths.Approach(tempSound.Volume, newVolume, fadeSpeed);
        }
示例#6
0
 // Stop horizontal speed
 public override void StopVertical()
 {
     // Approach 0 on Vertical speed
     physics.Velocity.Y = MyMaths.Approach(physics.Velocity.Y, 0, slowDownSpeed * GahameController.GameSpeed);
 }
示例#7
0
 // Stop horizontal speed
 public override void StopHorizontal()
 {
     // Approach 0 on horizontal speed
     physics.Velocity.X = MyMaths.Approach(physics.Velocity.X, 0, slowDownSpeed * GahameController.GameSpeed);
 }
 // Stop walking
 public override void StopHorizontal()
 {
     physics.Velocity.X = MyMaths.Approach(physics.Velocity.X, 0, GahameController.GameSpeed * (physics.Grounded ? slowDownSpeed : airSlowDownSpeed));
     spriteManager.ChangeSprite("Still");
 }