Example #1
0
        private void MakeBlock(Texture2D boxType, Vector2 position, bool ignore = false)
        {
            BoxObject box = new BoxObject();

            box.ActivatePhysics(world, boxType, scale);
            box.Position = position;
            box.BodyType = BodyType.Static;
            if (ignore)
            {
                box.Body.IgnoreCollisionWith(seamstress.Body);
            }
            objects.Add(box);
        }
Example #2
0
        public RibbonObject(World world, Texture2D texture, Vector2 pos, float linksize, Vector2 size, List <Vector2> path) :
            base(pos)
        {
            this.texture  = texture;
            dimension     = size;
            this.BodyType = BodyType.Static;

            for (int i = 1; i < path.Count; i++)
            {
                Vector2 point1 = path[i];
                Vector2 point2 = path[i - 1];

                double deltaX = point1.X - point2.X;
                double deltaY = point1.Y - point2.Y;

                double distance = Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY));
                float  numLinks = (float)distance / linksize;

                BoxObject link;
                for (int k = 0; k < numLinks; k++)
                {
                    link = new BoxObject();
                    link.ActivatePhysics(world, texture, 1 / 32f);

                    if (deltaX == 0)
                    {
                        link.Position = new Vector2(pos.X, pos.Y + (k * linksize));
                    }
                    else
                    {
                        link.Position = new Vector2(pos.X + (k * linksize), pos.Y);
                    }
                    link.BodyType = BodyType.Static;
                    bodies.Add(link);
                }
            }

            //BoxObject link = new BoxObject();
            //link.ActivatePhysics(world, texture);
            //link.Density = 100000f;
            //bodies.Add(link);
            //link = new BoxObject();
            //link.ActivatePhysics(world, texture);
            //link.Position = new Vector2(100, 100);
            //link.BodyType = BodyType.Static;
            //link.Density = 100000f;
            //bodies.Add(link);
        }
Example #3
0
        private void AddBox(World world, Texture2D tex)
        {
            Body attach1 = BodyFactory.CreateBody(world);

            attach1.BodyType = BodyType.Kinematic;
            attach1.Position = new Vector2(4, 7);


            Body attach2 = BodyFactory.CreateBody(world);

            attach2.BodyType = BodyType.Kinematic;
            attach2.Position = new Vector2(4, 9);

            box          = new BoxObject();
            box.Position = new Vector2(5, 8);
            box.BodyType = BodyType.Dynamic;
            box.ActivatePhysics(world, tex, 32f);
            box.Body.UserData = box;
            box.Body.IgnoreCollisionWith(body);
            RevoluteJoint j1 = JointFactory.CreateRevoluteJoint(world, box.Body, attach1, new Vector2(-1, -1));
            RevoluteJoint j2 = JointFactory.CreateRevoluteJoint(world, box.Body, attach2, new Vector2(-1, 1));

            hinges.Add(new Hinge(attach1, 8));
            hinges.Add(new Hinge(attach2, 10));

            Body attach3 = BodyFactory.CreateBody(world);

            attach3.BodyType = BodyType.Kinematic;
            attach3.Position = new Vector2(4, 12);


            Body attach4 = BodyFactory.CreateBody(world);

            attach4.BodyType = BodyType.Kinematic;
            attach4.Position = new Vector2(4, 14);

            box2          = new BoxObject();
            box2.Position = new Vector2(5, 17);
            box2.BodyType = BodyType.Dynamic;
            box2.ActivatePhysics(world, tex, 32f);
            box2.Body.UserData = box2;
            box2.Body.IgnoreCollisionWith(body);
            RevoluteJoint j3 = JointFactory.CreateRevoluteJoint(world, box2.Body, attach3, new Vector2(-1, -1));
            RevoluteJoint j4 = JointFactory.CreateRevoluteJoint(world, box2.Body, attach4, new Vector2(-1, 1));

            hinges.Add(new Hinge(attach3, 17));
            hinges.Add(new Hinge(attach4, 19));
        }
Example #4
0
        public RibbonObject(World world, Texture2D texture, Vector2 pos, float linksize, Vector2 size, List<Vector2> path)
            : base(pos)
        {
            this.texture = texture;
            dimension = size;
            this.BodyType = BodyType.Static;

            for(int i=1; i < path.Count; i++)
            {
                Vector2 point1 = path[i];
                Vector2 point2 = path[i - 1];

                double deltaX = point1.X - point2.X;
                double deltaY = point1.Y - point2.Y;

                double distance = Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY));
                float numLinks = (float)distance / linksize;

                BoxObject link;
                for (int k = 0; k < numLinks; k++)
                {
                    link = new BoxObject();
                    link.ActivatePhysics(world, texture, 1/32f);

                    if(deltaX == 0){
                        link.Position = new Vector2(pos.X, pos.Y + (k * linksize));
                    }
                    else{
                        link.Position = new Vector2(pos.X + (k * linksize), pos.Y);
                    }
                    link.BodyType = BodyType.Static;
                    bodies.Add(link);
                }
            }

            //BoxObject link = new BoxObject();
            //link.ActivatePhysics(world, texture);
            //link.Density = 100000f;
            //bodies.Add(link);
            //link = new BoxObject();
            //link.ActivatePhysics(world, texture);
            //link.Position = new Vector2(100, 100);
            //link.BodyType = BodyType.Static;
            //link.Density = 100000f;
            //bodies.Add(link);
        }
Example #5
0
        private void AddBox(World world, Texture2D tex)
        {
            Body attach1 = BodyFactory.CreateBody(world);
            attach1.BodyType = BodyType.Kinematic;
            attach1.Position = new Vector2(4, 7);

            Body attach2 = BodyFactory.CreateBody(world);
            attach2.BodyType = BodyType.Kinematic;
            attach2.Position = new Vector2(4, 9);

            box = new BoxObject();
            box.Position = new Vector2(5, 8);
            box.BodyType = BodyType.Dynamic;
            box.ActivatePhysics(world, tex, 32f);
            box.Body.UserData = box;
            box.Body.IgnoreCollisionWith(body);
            RevoluteJoint j1 = JointFactory.CreateRevoluteJoint(world, box.Body, attach1, new Vector2(-1, -1));
            RevoluteJoint j2 = JointFactory.CreateRevoluteJoint(world, box.Body, attach2, new Vector2(-1, 1));

            hinges.Add(new Hinge(attach1,8));
            hinges.Add(new Hinge(attach2,10));

            Body attach3 = BodyFactory.CreateBody(world);
            attach3.BodyType = BodyType.Kinematic;
            attach3.Position = new Vector2(4, 12);

            Body attach4 = BodyFactory.CreateBody(world);
            attach4.BodyType = BodyType.Kinematic;
            attach4.Position = new Vector2(4, 14);

            box2 = new BoxObject();
            box2.Position = new Vector2(5, 17);
            box2.BodyType = BodyType.Dynamic;
            box2.ActivatePhysics(world, tex, 32f);
            box2.Body.UserData = box2;
            box2.Body.IgnoreCollisionWith(body);
            RevoluteJoint j3 = JointFactory.CreateRevoluteJoint(world, box2.Body, attach3, new Vector2(-1, -1));
            RevoluteJoint j4 = JointFactory.CreateRevoluteJoint(world, box2.Body, attach4, new Vector2(-1, 1));

            hinges.Add(new Hinge(attach3, 17));
            hinges.Add(new Hinge(attach4, 19));
        }
Example #6
0
 private void MakeBlock(Texture2D boxType, Vector2 position, bool ignore = false)
 {
     BoxObject box = new BoxObject();
         box.ActivatePhysics(world, boxType, scale);
         box.Position = position;
         box.BodyType = BodyType.Static;
         if (ignore)
             box.Body.IgnoreCollisionWith(seamstress.Body);
         objects.Add(box);
 }