public static FunkyPoly CreateRandomShape(int sides = -1, int minSides = 3, int maxSides = 30, float minX = 0, float minY = 0, float maxX = 500, float maxY = 500, Brush brush = null) { if (sides < 3) { sides = rand.Next(maxSides - minSides) + minSides; } var points = new List<Vector>(); for (int i = 0; i < sides; i++) { points.Add(new Vector((float)(rand.NextDouble() * (maxX - minX) + minX), (float)(rand.NextDouble() * (maxY - minY) + minY))); } var phys = new PhysicsObject { Bounds = new Polygon(points), Mass = 100, Velocity = new Vector(1, 1), Theta = 0, DTheta = .01f }; if(brush == null) { brush = new SolidBrush(GraphicsHelper.RandomColor()); } return new FunkyPoly(phys, brush); }
public ARenderable(PhysicsObject PhysicsObject) { __TextureOffset = new Vector(0, 0); __TextureScale = new Vector(1, 1); __IsRendered = false; _PhysicsObject = (PhysicsObject)PhysicsObject; __Texture = new Bitmap(Width, Height); }
public static FunkyPoly CreateRectangle(float x, float y, float width, float height, Brush brush = null, Vector velocity = null, float dTheta = 0, float theta = 0, float mass = 100) { if (velocity == null) { velocity = new Vector(); } var phys = new PhysicsObject { Bounds = new RectanglePoly(x, y, width, height), Mass = mass, Velocity = velocity, Theta = theta, DTheta = dTheta }; if (brush == null) { brush = new SolidBrush(GraphicsHelper.RandomColor()); } return new FunkyPoly(phys, brush); }
private FunkyPoly(PhysicsObject phys, Brush Brush) : base(phys) { this.Brush = Brush; }
public bool Intersects(PhysicsObject other) { return this.Bounds.Intersects(other.Bounds); }