private static Rectangle CalculateArrowDrawArea(Material material, Vector2D start, Vector2D target) { start += Vector2D.Normalize(start.DirectionTo(target)) * 0.033f; target -= Vector2D.Normalize(start.DirectionTo(target)) * 0.033f; var distance = start.DistanceTo(target); var size = new Size(distance, distance / material.DiffuseMap.PixelSize.AspectRatio); return Rectangle.FromCenter((start + target) / 2, size * GameLogic.ArrowSize); }
private static Rectangle CalculateArrowDrawArea(Material material, Vector2D start, Vector2D target) { start += Vector2D.Normalize(start.DirectionTo(target)) * 0.033f; target -= Vector2D.Normalize(start.DirectionTo(target)) * 0.033f; var distance = start.DistanceTo(target); var size = new Size(distance, distance / material.DiffuseMap.PixelSize.AspectRatio); return(Rectangle.FromCenter((start + target) / 2, size * GameLogic.ArrowSize)); }
private void OnReleasing() { if (grabbedBall != null) { grabbedBall.LinearVelocity = lastMousePosition.DirectionTo(grabbedBall.Position) * 4f; } grabbedBall = null; }
private static void ZoomLinePoints(List <Vector2D> points, float zoomAmount) { Vector2D center = Vector2D.Half; for (int i = 0; i < points.Count; i++) { points[i] = center + center.DirectionTo(points[i]) * (1 + zoomAmount); } }
private Vector2D GetNextPathPosition(Vector2D formerPosition) { var nextPosition = formerPosition + formerPosition.DirectionTo(Path.Path[nextPathIndex].Position); if (nextPosition == Path.Path[nextPathIndex].Position) nextPathIndex++; if (nextPathIndex >= Path.Path.Count) { nextPathIndex = 1; nextPosition = Path.Path[0].Position; } lastPosition = nextPosition; return nextPosition + Vector2D.Half; }
private Vector2D GetNextPathPosition(Vector2D formerPosition) { var nextPosition = formerPosition + formerPosition.DirectionTo(Path.Path[nextPathIndex].Position); if (nextPosition == Path.Path[nextPathIndex].Position) { nextPathIndex++; } if (nextPathIndex >= Path.Path.Count) { nextPathIndex = 1; nextPosition = Path.Path[0].Position; } lastPosition = nextPosition; return(nextPosition + Vector2D.Half); }
private float GetRotation() { return(lastPosition.DirectionTo(Path.Path[nextPathIndex].Position).GetRotation() + 90.0f); }
public void DirectionTo() { Assert.AreEqual(new Vector2D(2, -6), v1.DirectionTo(v2)); }