Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public ARenderable(PhysicsObject PhysicsObject)
 {
     __TextureOffset = new Vector(0, 0);
     __TextureScale = new Vector(1, 1);
     __IsRendered = false;
     _PhysicsObject = (PhysicsObject)PhysicsObject;
     __Texture = new Bitmap(Width, Height);
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 private FunkyPoly(PhysicsObject phys, Brush Brush)
     : base(phys)
 {
     this.Brush = Brush;
 }
Exemplo n.º 5
0
 public bool Intersects(PhysicsObject other)
 {
     return this.Bounds.Intersects(other.Bounds);
 }