public static void DrawRectangleOutline(Vector2Rectangle r, Color c, int layer = 0) { DrawLine(new Vector2(r.Position.X, r.Position.Y), new Vector2(r.Position.X + r.Size.X - 1, r.Position.Y), c, layer); DrawLine(new Vector2(r.Position.X + r.Size.X, r.Position.Y), new Vector2(r.Position.X + r.Size.X, r.Position.Y + r.Size.Y - 1), c, layer); DrawLine(new Vector2(r.Position.X + r.Size.X, r.Position.Y + r.Size.Y), new Vector2(r.Position.X, r.Position.Y + r.Size.Y), c, layer); DrawLine(new Vector2(r.Position.X, r.Position.Y + r.Size.Y - 1), new Vector2(r.Position.X, r.Position.Y + 1), c, layer); }
public static void DrawRectangle(Vector2Rectangle r, Color c, int layer = 0) { SpriteBatch.Draw(WhitePixel, r.Position, null, c, 0, Vector2.Zero, r.Size, SpriteEffects.None, layer); }
public static Vector2 GetPenetrationVector(Vector2Rectangle vr1, Vector2Rectangle vr2) { Vector2 max1 = vr1.Position + vr1.Size; Vector2 max2 = vr2.Position + vr2.Size; if (vr1.Position.X < max2.X && max1.X > vr2.Position.X && vr1.Position.Y < max2.Y && max1.Y > vr2.Position.Y) { } else { return Vector2.Zero; } Vector2 mtd = new Vector2(); float left = vr2.Position.X - max1.X; float right = max2.X - vr1.Position.X; float top = vr2.Position.Y - max1.Y; float bottom = max2.Y - vr1.Position.Y; if (left > 0 || right < 0) { return Vector2.Zero; } if (top > 0 || bottom < 0) { return Vector2.Zero; } if (Math.Abs(left) < right) { mtd += new Vector2(left, 0); } else { mtd += new Vector2(right, 0); } if (Math.Abs(top) < bottom) { mtd += new Vector2(0, top); } else { mtd += new Vector2(0, bottom); } return mtd; }
public override void Update(GameTime gameTime) { Vector2Rectangle cr = new Vector2Rectangle(GetDrawPosition(), Size * Scale); Selected = Utilities.PointIsInRect(Wrack.Input.MousePosition, cr.GetRect()); base.Update(gameTime); }
public static bool AreIntersecting(Vector2Rectangle vr1, Vector2Rectangle vr2) { Vector2 max1 = vr1.Position + vr1.Size; Vector2 max2 = vr2.Position + vr2.Size; return vr1.Position.X < max2.X && max1.X > vr2.Position.X && vr1.Position.Y < max2.Y && max1.Y > vr2.Position.Y; }