// Update, does all of the shaking public override void Update(GameTime gameTime) { if (!timer.CheckAndTick()) { // random position Vector2 randomPos = new Vector2(r.Next(-(int)(intensity * intensity) / 2, (int)(intensity * intensity) / 2), r.Next(-(int)(intensity * intensity) / 2, (int)(intensity * intensity) / 2)); screen.CamController.Position += randomPos; // random rotation float newRotation = (float)RandomNumberBetween(-(intensity * intensity) / 2, intensity * intensity / 2) / 125; screen.CamController.Rotation += newRotation; // lerp back rotation screen.CamController.Rotation = MyMaths.Lerp(screen.CamController.Rotation, 0, .25f); // rumble boy if (GameInput.ControllerMode) { GamePad.SetVibration(0, .25f, .25f); } // deplete the intensity intensity -= deplete; } else { // set stuff back to normal and remove this screen.CamController.Rotation = 0; GamePad.SetVibration(0, 0, 0); screen.ScreenEffects.Remove(this); } }
// 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; }
public override void Update(GameTime gameTime) { if (deleteTimer.CheckAndTick()) { DestroyObject(); } Position = startPosition; for (int i = 0; i < 20; i++) { Position += speed; if (hb.PlaceMeeting <WallObject>(Position)) { break; } } thickness = MyMaths.Lerp(thickness, 0, .15f); base.Update(gameTime); }