Ejemplo n.º 1
0
        public static CircleShape CreateColoredCircle(Scalar radius, ushort vertexCount)
        {
            CircleShape shape = new CircleShape(radius, vertexCount);
            var reduced = VertexHelper.Reduce(shape.Vertexes);
            var polygon = new ColoredPolygon(reduced, CreateColor3Array(reduced.Length));

            shape.Tag = DrawableFactory.GetOrCreateColoredPolygonDrawable(polygon, Drawables.ShapeType.Mesh);
            return shape;
        }
Ejemplo n.º 2
0
 public Bullet()
 {
     Coefficients coffecients = new Coefficients(/*restitution*/1, /*friction*/.5f);
     CircleShape circleShape = new CircleShape(6f, 7);
     float mass = 1f;
     Body = new Body(new PhysicsState(), circleShape, mass, coffecients, new Lifespan());
     Body.IsCollidable = true;
     Body.CollisionIgnorer = new BulletIgnorer();
     Body.Tag = "BulletTag";
     Body.Collided += new System.EventHandler<CollisionEventArgs>(Body_Collided);
     Origin.X = 14;
     Origin.Y = 15;
 }
Ejemplo n.º 3
0
 public Player()
 {
     Coefficients coffecients = new Coefficients(/*restitution*/1, /*friction*/.5f);
     CircleShape circleShape = new CircleShape(80, 9);
     float mass = 10000;
     Body = new Body(new PhysicsState(), circleShape, mass, coffecients, new Lifespan());
     Body.IsCollidable = true;
     Body.CollisionIgnorer = new PlayerIgnorer();
     Body.Tag = "PlayerTag";
     Body.Collided += new System.EventHandler<CollisionEventArgs>(Body_Collided);
     Origin.X = 73;
     Origin.Y = 73;
     Health = 1000;
 }
Ejemplo n.º 4
0
 public static CircleShape CreateColoredCircle(Scalar radius, int vertexCount)
 {
     CircleShape shape = new CircleShape(radius, vertexCount);
     shape.Tag = DrawableFactory.CreatePolygon(shape.Vertexes, CreateColor3Array(vertexCount));
     return shape;
 }
Ejemplo n.º 5
0
 public static CircleShape CreateCircle(Scalar radius, int vertexCount, ScalarColor4[] colors)
 {
     CircleShape shape = new CircleShape(radius, vertexCount);
     shape.Tag = DrawableFactory.CreatePolygon(shape.Vertexes, colors);
     return shape;
 }
Ejemplo n.º 6
0
 public Arbiter(SequentialImpulsesSolver parent, Body body1, Body body2)
 {
     if (body1.ID < body2.ID)
     {
         this.body1 = body1;
         this.body2 = body2;
     }
     else
     {
         this.body1 = body2;
         this.body2 = body1;
     }
     this.tag1 = (SequentialImpulsesTag)this.body1.SolverTag;
     this.tag2 = (SequentialImpulsesTag)this.body2.SolverTag;
     this.circle1 = this.body1.Shape as CircleShape;
     this.circle2 = this.body2.Shape as CircleShape;
     this.friction = MathHelper.Sqrt(
             this.body1.Coefficients.DynamicFriction *
             this.body2.Coefficients.DynamicFriction);
     this.restitution = Math.Min(body1.Coefficients.Restitution, body2.Coefficients.Restitution);
     this.parent = parent;
     this.contacts = new LinkedList<ContactPoint>();
     this.lastUpdate = -1;
     this.state = ContactState.New;
     this.ignoresCollisionResponse = body1.IgnoresCollisionResponse || body2.IgnoresCollisionResponse;
 }
Ejemplo n.º 7
0
        Body AddCircle(Scalar radius, int vertexCount, Scalar mass, ALVector2D position)
        {

            IShape circleShape = new CircleShape(radius, vertexCount); ;
            Body e =
                new Body(
                     new PhysicsState(position),
                     circleShape,
                     mass,
                     coefficients.Duplicate(),
                     new Lifespan());
            AddGlObject(e);
            engine.AddBody(e);
            return e;

        }
Ejemplo n.º 8
0
        void AddCircles_StressTest()
        {

            Scalar box = 550;
            Scalar xmin = 0;
            Scalar xmax = box;
            Scalar ymin = 0;
            Scalar ymax = box;

            Scalar size = 15;
            Scalar spacing = 2;

           // Particle shape = new Particle(); 
            CircleShape shape = new CircleShape(7, 10);
            List<Body> bodies = new List<Body>();
            for (Scalar x = xmin; x < xmax; x += spacing + size)
            {
                for (Scalar y = ymax; y > ymin; y -= spacing + size)
                {
                    Body e =
                    new Body(
                         new PhysicsState(new ALVector2D(0, new Vector2D(x, y))),
                         shape,
                         20,
                         coefficients.Duplicate(),
                         new Lifespan());


                    bodies.Add(e);
                }
            }
            AddGlObjectRange(bodies);
            engine.AddBodyRange(bodies);
        }