public void Offset(Vector2D vector) { for(int i = 0; i < Vertices.Count; ++i) { Point2D vertex = Vertices[i]; Vertices[i] = new Point2D(vertex.X + vector.i, vertex.Y + vector.j); } }
/// <summary> /// Colides Method, checks for entity collisions. /// </summary> /// <param name="entity">Entity to check against.</param> public virtual bool Colides(Entity entity) { flag = false; foreach (Bounding hitbox in _hitboxes) { foreach (Bounding check in entity.Hitboxes) { Vector2D polygonATranslation = new Vector2D(); PolygonCollisionResult r = hitbox.PolygonCollision(hitbox.Polygon, check.Polygon, _movement.Delta); if (r.WillIntersect) { // Move the polygon by its velocity, then move // the polygons appart using the Minimum Translation Vector polygonATranslation = _movement.Delta + r.MinimumTranslationVector; } else { // Just move the polygon by its velocity polygonATranslation = _movement.Delta; } polygonA.Offset(polygonATranslation); } } return false; }
public void Offset(Vector2D vector) { _position = new Point2D(_position.X + vector.i, _position.Y + vector.j); }
public double Dot(Vector2D vector) { return Magnitude * vector.Magnitude * Math.Cos(Direction - vector.Magnitude); }