コード例 #1
0
ファイル: Level_1.cs プロジェクト: eerkko/TUGameDev2012
        public Level_1(List<Texture2D> textures, SpriteBatch batch)
            : base(textures, batch)
        {
            this.size.X = 500;
            this.size.Y = 1000;
            this.timeFactor = 2.0f;

            ball1 = new Ball(new Vector2(50, 10), 10.0f, 10000f, Color.IndianRed, batch, textures[1], world);
            ball1.body.BodyType = BodyType.Dynamic;
            gamefield.add(ball1);
            addToMyOnCollision(ball1);

            ball2 = new Ball(new Vector2(485, 15), 15.0f, 10000f, Color.HotPink, batch, textures[3], world);
            ball2.body.BodyType = BodyType.Dynamic;
            gamefield.add(ball2);
            addToMyOnCollision(ball2);

            gamefield.add(new SquareStack(new Vector2(18, 40), new Vector2(50, 10), new Vector2(10, 5), 0.6f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(61, 64), new Vector2(50, 10), new Vector2(10, 5), 0.4f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(181, 93), new Vector2(200, 10), new Vector2(10, 5), 0.2f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(293, 115), new Vector2(30, 10), new Vector2(10, 5), 0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new Pipeline(new Vector2(293, 100), new Vector2(30, 30), 3.0f, 0.1f, Color.Green, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(447, 116), new Vector2(120, 10), new Vector2(10, 5), -0.5f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(320, 200), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(220, 230), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(400, 230), new Vector2(90, 10), new Vector2(10, 5), 0.3f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(120, 260), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(18, 340), new Vector2(50, 10), new Vector2(10, 5), 0.6f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(61, 364), new Vector2(50, 10), new Vector2(10, 5), 0.4f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(181, 393), new Vector2(200, 10), new Vector2(10, 5), 0.2f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(293, 415), new Vector2(30, 10), new Vector2(10, 5), 0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(447, 416), new Vector2(120, 10), new Vector2(10, 5), -0.5f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(320, 500), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(220, 530), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(400, 530), new Vector2(90, 10), new Vector2(10, 5), 0.3f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(120, 560), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(18, 640), new Vector2(50, 10), new Vector2(10, 5), 0.6f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(61, 664), new Vector2(50, 10), new Vector2(10, 5), 0.4f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(181, 693), new Vector2(200, 10), new Vector2(10, 5), 0.2f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(293, 715), new Vector2(30, 10), new Vector2(10, 5), 0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(447, 716), new Vector2(120, 10), new Vector2(10, 5), -0.5f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(320, 800), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(220, 830), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(400, 830), new Vector2(90, 10), new Vector2(10, 5), 0.3f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(120, 860), new Vector2(80, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(18, 925), new Vector2(50, 10), new Vector2(10, 5), 0.6f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(61, 949), new Vector2(50, 10), new Vector2(10, 5), 0.4f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(181, 978), new Vector2(200, 10), new Vector2(10, 5), 0.2f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new SquareStack(new Vector2(447, 971), new Vector2(120, 10), new Vector2(10, 5), -0.5f, Color.Green, Color.LightGreen, batch, textures[0], world));

            gamefield.add(new Triangle(new Vector2(350,975), new Vector2(50,50), 0.0f, batch, textures[7], world));

            // bonus objects
            bonus = new List<GameObject>();
            bonusLifetime = new List<int>();
            bonus.Add(new Egg(new Vector2(150, 360), 15.0f, 13.0f, Color.Green, batch, textures[1], world));
            bonus.Add(new Ball(new Vector2(150, 660), 12.0f, Color.Red, batch, textures[4], world));
            bonus.Add(new Ball(new Vector2(150, 945), 10.0f, Color.Yellow, batch, textures[4], world));

            foreach (GameObject obj in bonus)
            {
                gamefield.add( obj );
                addToMyOnCollision( obj );
                bonusLifetime.Add( maxLifetime );
            }

            // border
            gamefield.add(new Square(new Vector2(size.X / 2, 0), new Vector2(size.X, 7), 0.0f, Color.DarkGreen, batch, textures[0], world));
            gamefield.add(new Square(new Vector2(size.X / 2, size.Y ), new Vector2(size.X, 7), 0.0f, Color.DarkGreen, batch, textures[0], world));

            gamefield.add(new Square(new Vector2(0, size.Y / 2), new Vector2(7, size.Y), 0.0f, Color.DarkGreen, batch, textures[0], world));
            gamefield.add(new Square(new Vector2(size.X, size.Y / 2), new Vector2(7, size.Y), 0.0f, Color.DarkGreen, batch, textures[0], world));

            // add objects

            addObjects.add( new Egg(new Vector2(0, 0), 15.0f, 13.0f, Color.Blue, batch, textures[1], world) );
            addObjects.add(new SquareStack(new Vector2(0, 0), new Vector2(50, 15), new Vector2(10, 5), -0.4f, Color.Blue, Color.LightBlue, batch, textures[0], world));
            addObjects.add(new Ball(new Vector2(0, 0), 13.0f, Color.Blue, batch, textures[1], world));
            addObjects.add(new SquareStack(new Vector2(0, 0), new Vector2(80, 10), new Vector2(10, 5), 0.0f, Color.Blue, Color.LightBlue, batch, textures[0], world));
            addObjects.add(new Square(new Vector2(0, 0), new Vector2(40, 45), 0.2f, Color.Blue, batch, textures[0], world));
            addObjects.add(new SquareStack(new Vector2(0, 0), new Vector2(50, 15), new Vector2(10, 5), 0.4f, Color.Blue, Color.LightBlue, batch, textures[0], world));
            addObjects.add(new Triangle(new Vector2(0, 0), new Vector2(50, 50), 0.0f, Color.Blue, batch, textures[7], world));

            foreach (GameObject obj in addObjects.objects)
            {
                obj.body.BodyType = BodyType.Dynamic;
            }
        }
コード例 #2
0
ファイル: Level_2.cs プロジェクト: eerkko/TUGameDev2012
        public Level_2(List<Texture2D> textures, SpriteBatch batch)
            : base(textures, batch)
        {
            this.size.X = 500;
            this.size.Y = 800;
            this.timeFactor = 1.5f;

            ball1 = new Ball(new Vector2(50, 30), 11.0f, 10000f, Color.HotPink, batch, textures[5], world);
            ball1.body.BodyType = BodyType.Static;
            gamefield.add(ball1);
            addToMyOnCollision(ball1);

            ball2 = new Ball(new Vector2(480, 195), 15.0f, 10000f, Color.HotPink, batch, textures[2], world);
            ball2.body.BodyType = BodyType.Static;
            gamefield.add(ball2);
            addToMyOnCollision(ball2);

            // left
            gamefield.add(new SquareStack(new Vector2(40, 100), new Vector2(100, 10), new Vector2(10, 5), 0.0f, Color.Green, Color.LightGreen, batch, textures[0], world));
            //arrow 1
            gamefield.add(new SquareStack(new Vector2(90, 220), new Vector2(100, 10), new Vector2(10, 5), -0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(155, 220), new Vector2(100, 10), new Vector2(10, 5), 0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));
            //vertical one:
            gamefield.add(new SquareStack(new Vector2(122, 280), new Vector2(10, 160), new Vector2(10, 5), 0.0f, Color.Green, Color.LightGreen, batch, textures[0], world));
            //arrow 2
            gamefield.add(new SquareStack(new Vector2(90, 410), new Vector2(100, 10), new Vector2(10, 5), -0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(155, 410), new Vector2(100, 10), new Vector2(10, 5), 0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));
            //vertical one:
            gamefield.add(new SquareStack(new Vector2(122, 470), new Vector2(10, 160), new Vector2(10, 5), 0.0f, Color.Green, Color.LightGreen, batch, textures[0], world));
            //arrow 3
            gamefield.add(new SquareStack(new Vector2(90, 600), new Vector2(100, 10), new Vector2(10, 5), -0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(155, 600), new Vector2(100, 10), new Vector2(10, 5), 0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(120, 700), new Vector2(260, 10), new Vector2(10, 5), 0.2f, Color.Green, Color.LightGreen, batch, textures[0], world));

            // right
            gamefield.add(new SquareStack(new Vector2(420, 250), new Vector2(150, 10), new Vector2(10, 5), -0.5f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(350, 200), new Vector2(200, 10), new Vector2(10, 5), -0.5f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(320, 320), new Vector2(100, 10), new Vector2(10, 5), 0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(370, 425), new Vector2(100, 10), new Vector2(10, 5), -0.8f, Color.Green, Color.LightGreen, batch, textures[0], world));

            //vertical one:
            gamefield.add(new SquareStack(new Vector2(280, 400), new Vector2(10, 160), new Vector2(10, 5), 0.0f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(370, 570), new Vector2(230, 10), new Vector2(10, 5), 0.7f, Color.Green, Color.LightGreen, batch, textures[0], world));
            gamefield.add(new SquareStack(new Vector2(450, 730), new Vector2(100, 10), new Vector2(10, 5), -0.1f, Color.Green, Color.LightGreen, batch, textures[0], world));

            // border
            bottomBorder = new Square(new Vector2(size.X / 2, size.Y), new Vector2(size.X, 7), 0.0f, Color.DarkGreen, batch, textures[0], world);
            gamefield.add(bottomBorder);
            gamefield.add(new Square(new Vector2(size.X / 2, 0), new Vector2(size.X, 7), 0.0f, Color.DarkGreen, batch, textures[0], world));
            gamefield.add(new Square(new Vector2(0, size.Y / 2), new Vector2(7, size.Y), 0.0f, Color.DarkGreen, batch, textures[0], world));
            gamefield.add(new Square(new Vector2(size.X, size.Y / 2), new Vector2(7, size.Y), 0.0f, Color.DarkGreen, batch, textures[0], world));

            // bonus objects
            bonus = new List<GameObject>();
            bonusScore = new List<int>();
            bonus.Add(new Ball(new Vector2(400, 430), 12.0f, Color.LightGreen, batch, textures[4], world));

            foreach (GameObject obj in bonus)
            {
                gamefield.add(obj);
                addToMyOnCollision(obj);
                bonusScore.Add(score);
            }

            // add objects
            addObjects.add(new Egg(new Vector2(0, 0), 15.0f, 13.0f, Color.Blue, batch, textures[1], world));
            addObjects.add(new SquareStack(new Vector2(0, 0), new Vector2(50, 15), new Vector2(10, 5), -0.4f, Color.Blue, Color.LightBlue, batch, textures[0], world));
            addObjects.add(new SquareStack(new Vector2(0, 0), new Vector2(60, 10), new Vector2(10, 5), -0.4f, Color.Blue, Color.LightBlue, batch, textures[0], world));
            addObjects.add(new Ball(new Vector2(0, 0), 13.0f, Color.Blue, batch, textures[1], world));
            addObjects.add(new SquareStack(new Vector2(0, 0), new Vector2(80, 10), new Vector2(10, 5), 0.0f, Color.Blue, Color.LightBlue, batch, textures[0], world));
            addObjects.add(new Square(new Vector2(0, 0), new Vector2(20, 20), 0.2f, Color.Blue, batch, textures[0], world));
            addObjects.add(new SquareStack(new Vector2(0, 0), new Vector2(50, 15), new Vector2(10, 5), 0.4f, Color.Blue, Color.LightBlue, batch, textures[0], world));
            addObjects.add(new Triangle(new Vector2(0, 0), new Vector2(50, 50), 0.0f, Color.Blue, batch, textures[7], world));

            foreach (GameObject obj in addObjects.objects)
            {
                obj.isMoveable = true;
                obj.body.FixedRotation = true;
                obj.body.BodyType = BodyType.Dynamic;
            }
        }