Esempio n. 1
0
        public Level(Game game, Score score, Scene gameOverScene, Level nextLevel)
            : base(game)
        {
            this.game = game;
            spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
            soundCenter = (SoundCenter)game.Services.GetService(typeof(SoundCenter));
            font = (SpriteFont)game.Services.GetService(typeof(SpriteFont));

            bg = new Background(game);
            paddle = new Paddle(game);
            ball = new Ball(game);
            this.score = score;
            this.gameOverScene = gameOverScene;
            this.nextLevel = nextLevel;

            SceneComponents.Add(bg);
            SceneComponents.Add(paddle);
            SceneComponents.Add(ball);
            SceneComponents.Add(this.score);

            // pause paddle and ball until start
            paddle.Enabled = false;
            ball.Enabled = false;

            bricks = new List<Brick>();

            CreateBricks();
        }
Esempio n. 2
0
 public Ball(Game game)
     : base(game)
 {
     this.game = game;
     sprite = game.Content.Load<Texture2D>("ball");
     spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
     soundCenter = (SoundCenter)game.Services.GetService(typeof(SoundCenter));
     ResetBall();
 }
Esempio n. 3
0
        public GameOverScene(Game game, Score score)
            : base(game)
        {
            this.game = game;
            spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
            soundCenter = (SoundCenter)game.Services.GetService(typeof(SoundCenter));
            font = (SpriteFont)game.Services.GetService(typeof(SpriteFont));

            this.score = score;

            SceneComponents.Add(this.score);
        }
Esempio n. 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            soundCenter = new SoundCenter(this);
            font = Content.Load<SpriteFont>("MyFont");

            Services.AddService(typeof(SpriteBatch), spriteBatch);
            Services.AddService(typeof(SoundCenter), soundCenter);
            Services.AddService(typeof(SpriteFont), font);

            score = new Score(this);
            Components.Add(score);

            gameOverScene = new GameOverScene(this, score);
            gameOverScene.Hide();

            level2 = new Level2(this, score, gameOverScene, null);
            level1 = new Level1(this, score, gameOverScene, level2);

            Components.Add(level1);
            Components.Add(level2);
            Components.Add(gameOverScene);

            level1.Show();
            level2.Hide();

            curScene = level2;
        }