public static void Update() { if (Input.IsScrollMvdUp) { ScaleInput = Scale * 1.3f; } if (Input.IsScrollMvdDown) { ScaleInput = Scale / 1.3f; } GameDebugger.WriteLine("scale: " + Scale); GameDebugger.WriteLine($"scaleinput {ScaleInput}"); if (ScreenShakeDuration > 0) { ScreenShakeDuration -= Time.DeltaTime; Position += new Vector2(Game1.Random.NextFloat(-1, 1) * ScreenShakeIntensity, Game1.Random.NextFloat(-1, 1) * ScreenShakeIntensity); } if (Input.CurrentMouse.RightButton == ButtonState.Pressed && Focus == null) { Position -= Vector2.TransformNormal(Input.MouseMovement, Matrix.Invert(Transform)); } if (Focus != null) { Position = Vector2.Lerp(Position, Focus.Value, FocusSpeed * Time.DeltaTime); } Scale = MathHelper.Lerp(Scale, ScaleInput, Time.DeltaTime * ScaleSpeed); }
public override void Update() { base.Update(); GroundPosition = Position + Center + groundPositionOffset; float angle = (float)Math.Atan2(direction.Y, direction.X); float pi8 = (float)Math.PI / 8; if (angle > -pi8 && angle < pi8) { facingDirection = FacingDirection.East; } else if (angle > pi8 && angle < pi8 * 3) { facingDirection = FacingDirection.SouthEast; } else if (angle > pi8 * 3 && angle < pi8 * 5) { facingDirection = FacingDirection.South; } else if (angle > pi8 * 5 && angle < pi8 * 7) { facingDirection = FacingDirection.SouthWest; } else if (angle > pi8 * 7 || angle < -pi8 * 7) { facingDirection = FacingDirection.West; } else if (angle < -pi8 && angle > -pi8 * 3) { facingDirection = FacingDirection.NorthEast; } else if (angle < -pi8 * 3 && angle > -pi8 * 5) { facingDirection = FacingDirection.North; } else if (angle < -pi8 * 5 && angle > -pi8 * 7) { facingDirection = FacingDirection.NorthWest; } //beräknar ut riktning på creature if (GetType() == typeof(Player)) { GameDebugger.WriteLine("player direction: " + facingDirection); } if (Stats.Health <= 0) { Die(); return; } if (invulnerable) { InvulnerabilityTimer(); } }