コード例 #1
0
ファイル: Rotator.cs プロジェクト: tgjones/apesharp
        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);
        }
コード例 #2
0
ファイル: Capsule.cs プロジェクト: tgjones/apesharp
        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);
        }
コード例 #3
0
ファイル: RectComposite.cs プロジェクト: tgjones/apesharp
        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);
        }
コード例 #4
0
ファイル: Bridge.cs プロジェクト: tgjones/apesharp
        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);
        }
コード例 #5
0
ファイル: Surfaces.cs プロジェクト: tgjones/apesharp
        public Surfaces(int colA, int colB, int colC, int colD, int colE, int colBouncePad)
            : base(false)
        {
            floor = new RectangleParticle(340, 327, 550, 50, 0, true, 1.0f, 0.3f, 0);
            floor.SetStyle(0, colD, colD);
            this.Particles.Add(floor);

            ceil = new RectangleParticle(325, -33, 649, 80, 0, true, 1.0f, 0.3f, 0);
            ceil.SetStyle(0, colD, colD);
            this.Particles.Add(ceil);

            rampRight = new RectangleParticle(375, 220, 390, 20, 0.405f, true, 1.0f, 0.3f, 0);
            rampRight.SetStyle(0, colD, colD);
            this.Particles.Add(rampRight);

            rampLeft = new RectangleParticle(90, 200, 102, 20, -.7f, true, 1.0f, 0.3f, 0);
            rampLeft.SetStyle(0, colD, colD);
            this.Particles.Add(rampLeft);

            rampLeft2 = new RectangleParticle(96, 129, 102, 20, -.7f, true, 1.0f, 0.3f, 0);
            rampLeft2.SetStyle(0, colD, colD);
            this.Particles.Add(rampLeft2);

            rampCircle = new CircleParticle(175, 190, 60, true, 1.0f, 0.3f, 0);
            rampCircle.SetStyle(1, colD, colB);
            this.Particles.Add(rampCircle);

            floorBump = new CircleParticle(600, 660, 400, true, 1.0f, 0.3f, 0);
            floorBump.SetStyle(1, colD, colB);
            this.Particles.Add(floorBump);

            bouncePad = new RectangleParticle(30, 370, 32, 60, 0, true, 1.0f, 0.3f, 0);
            bouncePad.SetStyle(1, colD, colBouncePad);
            bouncePad.Elasticity = 4;
            this.Particles.Add(bouncePad);

            leftWall = new RectangleParticle(1, 99, 30, 500, 0, true, 1.0f, 0.3f, 0);
            leftWall.SetStyle(0, colD, colD);
            this.Particles.Add(leftWall);

            leftWallChannelInner = new RectangleParticle(54, 300, 20, 150, 0, true, 1.0f, 0.3f, 0);
            leftWallChannelInner.SetStyle(0, colD, colD);
            this.Particles.Add(leftWallChannelInner);

            leftWallChannel = new RectangleParticle(54, 122, 20, 94, 0, true, 1.0f, 0.3f, 0);
            leftWallChannel.SetStyle(0, colD, colD);
            this.Particles.Add(leftWallChannel);

            leftWallChannelAng = new RectangleParticle(75, 65, 60, 25, -0.7f, true, 1.0f, 0.3f, 0);
            leftWallChannelAng.SetStyle(0, colD, colD);
            this.Particles.Add(leftWallChannelAng);

            topLeftAng = new RectangleParticle(23, 11, 65, 40, -0.7f, true, 1.0f, 0.3f, 0);
            topLeftAng.SetStyle(0, colD, colD);
            this.Particles.Add(topLeftAng);

            rightWall = new RectangleParticle(654, 230, 50, 500, 0, true, 1.0f, 0.3f, 0);
            rightWall.SetStyle(0, colD, colD);
            this.Particles.Add(rightWall);

            bridgeStart = new RectangleParticle(127, 49, 75, 25, 0, true, 1.0f, 0.3f, 0);
            bridgeStart.SetStyle(0, colD, colD);
            this.Particles.Add(bridgeStart);

            bridgeEnd = new RectangleParticle(483, 55, 100, 15, 0, true, 1.0f, 0.3f, 0);
            bridgeEnd.SetStyle(0, colD, colD);
            this.Particles.Add(bridgeEnd);
        }