Exemple #1
0
        public Rotator(int colA, int colB)
            : base(false)
        {
            this.CollideInternal = true;

            ctr = new Vector(555, 175);
            rectComposite = new RectComposite(ctr, colA, colB);
            addComposite(rectComposite);

            circA = new CircleParticle(ctr.X, ctr.Y, 5, false, 1, 0.3f, 0);
            circA.SetStyle(1, colA, colB);
            this.Particles.Add(circA);

            rectA = new RectangleParticle(555, 160, 10, 10, 0, false, 3, 0.3f, 0);
            rectA.SetStyle(1, colA, colB);
            this.Particles.Add(rectA);

            connectorA = new SpringConstraint(rectComposite.PA, rectA, 1, false, 1, 1, false);
            connectorA.SetStyle(2, colB);
            this.Constraints.Add(connectorA);

            rectB = new RectangleParticle(555, 190, 10, 10, 0, false, 3, 0.3f, 0);
            rectB.SetStyle(1, colA, colB);
            this.Particles.Add(rectB);

            connectorB = new SpringConstraint(rectComposite.PC, rectB, 1, false, 1, 1, false);
            connectorB.SetStyle(2, colB);
            this.Constraints.Add(connectorB);
        }
Exemple #2
0
        public Capsule(int colC)
            : base(false)
        {
            CircleParticle capsuleP1 = new CircleParticle(300, 10, 14, false, 1.3f, 0.4f, 0);
            capsuleP1.SetStyle(0, colC, colC);
            this.Particles.Add(capsuleP1);

            CircleParticle capsuleP2 = new CircleParticle(325, 35, 14, false, 1.3f, 0.4f, 0);
            capsuleP2.SetStyle(0, colC, colC);
            this.Particles.Add(capsuleP2);

            SpringConstraint capsule = new SpringConstraint(capsuleP1, capsuleP2, 1, true, 24, 1, false);
            capsule.SetStyle(0, colC, colC);
            this.Constraints.Add(capsule);
        }
Exemple #3
0
        public Car(int colC, int colE)
            : base(false)
        {
            wheelParticleA = new WheelParticle(140, 10, 14, false, 2, 0.3f, 0, 1);
            wheelParticleA.SetStyle(1, colC, colE);
            this.Particles.Add(wheelParticleA);

            wheelParticleB = new WheelParticle(200, 10, 14, false, 2, 0.3f, 0, 1);
            wheelParticleB.SetStyle(1, colC, colE);
            this.Particles.Add(wheelParticleB);

            SpringConstraint wheelConnector = new SpringConstraint(wheelParticleA, wheelParticleB,
                    0.5f, true, 8, 1, false);
            wheelConnector.SetStyle(1, colC, colE);
            this.Constraints.Add(wheelConnector);
        }
Exemple #4
0
        public RectComposite(Vector ctr, int colA, int colB)
            : base()
        {
            float rw = 75;
            float rh = 18;
            float rad = 4;

            // going clockwise from left top..
            cpA = new CircleParticle(ctr.X - rw / 2, ctr.Y - rh / 2, rad, true, 1, 0.3f, 0);
            cpB = new CircleParticle(ctr.X + rw / 2, ctr.Y - rh / 2, rad, true, 1, 0.3f, 0);
            cpC = new CircleParticle(ctr.X + rw / 2, ctr.Y + rh / 2, rad, true, 1, 0.3f, 0);
            cpD = new CircleParticle(ctr.X - rw / 2, ctr.Y + rh / 2, rad, true, 1, 0.3f, 0);

            cpA.SetStyle(0, 0, colA);
            cpB.SetStyle(0, 0, colA);
            cpC.SetStyle(0, 0, colA);
            cpD.SetStyle(0, 0, colA);

            sprA = new SpringConstraint(cpA, cpB, 0.5f, true, rad * 2, 1, false);
            sprB = new SpringConstraint(cpB, cpC, 0.5f, true, rad * 2, 1, false);
            sprC = new SpringConstraint(cpC, cpD, 0.5f, true, rad * 2, 1, false);
            sprD = new SpringConstraint(cpD, cpA, 0.5f, true, rad * 2, 1, false);

            sprA.SetStyle(0, 0, colA);
            sprB.SetStyle(0, 0, colA);
            sprC.SetStyle(0, 0, colA);
            sprD.SetStyle(0, 0, colA);

            this.Particles.Add(cpA);
            this.Particles.Add(cpB);
            this.Particles.Add(cpC);
            this.Particles.Add(cpD);

            this.Constraints.Add(sprA);
            this.Constraints.Add(sprB);
            this.Constraints.Add(sprC);
            this.Constraints.Add(sprD);
        }
Exemple #5
0
        public Bridge(int colB, int colC, int colD)
            : base(false)
        {
            float bx = 170;
            float by = 40;
            float bsize = 51.5f;
            float yslope = 2.4f;
            float particleSize = 4;

            bridgePAA = new CircleParticle(bx, by, particleSize, true, 1, 0.3f, 0);
            bridgePAA.SetStyle(1, colC, colB);
            this.Particles.Add(bridgePAA);

            bx += bsize;
            by += yslope;
            bridgePA = new CircleParticle(bx, by, particleSize, false, 1, 0.3f, 0);
            bridgePA.SetStyle(1, colC, colB);
            this.Particles.Add(bridgePA);

            bx += bsize;
            by += yslope;
            bridgePB = new CircleParticle(bx, by, particleSize, false, 1, 0.3f, 0);
            bridgePB.SetStyle(1, colC, colB);
            this.Particles.Add(bridgePB);

            bx += bsize;
            by += yslope;
            bridgePC = new CircleParticle(bx, by, particleSize, false, 1, 0.3f, 0);
            bridgePC.SetStyle(1, colC, colB);
            this.Particles.Add(bridgePC);

            bx += bsize;
            by += yslope;
            bridgePD = new CircleParticle(bx, by, particleSize, false, 1, 0.3f, 0);
            bridgePD.SetStyle(1, colC, colB);
            this.Particles.Add(bridgePD);

            bx += bsize;
            by += yslope;
            bridgePDD = new CircleParticle(bx, by, particleSize, true, 1, 0.3f, 0);
            bridgePDD.SetStyle(1, colC, colB);
            this.Particles.Add(bridgePDD);

            bridgeConnA = new SpringConstraint(bridgePAA, bridgePA,
                    0.9f, true, 10, 0.8f, false);

            // collision response on the bridgeConnA will be ignored on
            // on the first 1/4 of the constraint. this avoids blow ups
            // particular to springcontraints that have 1 fixed particle.
            bridgeConnA.FixedEndLimit = 0.25f;
            bridgeConnA.SetStyle(1, colC, colB);
            this.Constraints.Add(bridgeConnA);

            bridgeConnB = new SpringConstraint(bridgePA, bridgePB,
                    0.9f, true, 10, 0.8f, false);
            bridgeConnB.SetStyle(1, colC, colB);
            this.Constraints.Add(bridgeConnB);

            bridgeConnC = new SpringConstraint(bridgePB, bridgePC,
                    0.9f, true, 10, 0.8f, false);
            bridgeConnC.SetStyle(1, colC, colB);
            this.Constraints.Add(bridgeConnC);

            bridgeConnD = new SpringConstraint(bridgePC, bridgePD,
                    0.9f, true, 10, 0.8f, false);
            bridgeConnD.SetStyle(1, colC, colB);
            this.Constraints.Add(bridgeConnD);

            bridgeConnE = new SpringConstraint(bridgePD, bridgePDD,
                    0.9f, true, 10, 0.8f, false);
            bridgeConnE.FixedEndLimit = 0.25f;
            bridgeConnE.SetStyle(1, colC, colB);
            this.Constraints.Add(bridgeConnE);
        }