示例#1
0
 public Ball(GameHost game, Vector2 position, Texture2D texture, Score score)
     : this(game, position)
 {
     // Store the provided texture
     SpriteTexture = texture;
     this.score = score;
 }
        public void SetGame()
        {
            //create player
            Player player = new Player(this, new Vector2(800,800), playerTexture2D);
            GameObjects.Add(player);

            // create ball

            for (int i = 0; i < 25; i++)
            {
                Block b = new Block(this, new Vector2(100+i*60, 100), blockTexture2Dblue );
                GameObjects.Add(b);

                Block b2 = new Block(this, new Vector2(100+i*60, 130), blockTexture2Dgrey );
                GameObjects.Add(b2);

                Block b3 = new Block(this, new Vector2(100+i*60, 160), blockTexture2Dgreen );
                GameObjects.Add(b3);

                Block b4 = new Block(this, new Vector2(100+i*60, 190), blockTexture2Dpurple );
                GameObjects.Add(b4);

                Block b5 = new Block(this, new Vector2(100 + i * 60, 210), blockTexture2Dblue);
                GameObjects.Add(b5);

                Block b6 = new Block(this, new Vector2(100 + i * 60, 240), blockTexture2Dgrey);
                GameObjects.Add(b6);

                Block b7 = new Block(this, new Vector2(100 + i * 60, 270), blockTexture2Dgreen);
                GameObjects.Add(b7);

                Block b8 = new Block(this, new Vector2(100 + i * 60, 320), blockTexture2Dpurple);
                GameObjects.Add(b8);
            }
            score = new Score(this, _segoe, new Vector2(900, 50));
            score.Text = "Score: 0";
            GameObjects.Add(score);

            Ball ball = new Ball(this, new Vector2(100, 400), ballTexture2D, score);
            GameObjects.Add(ball);
        }