/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); GraphicsDeviceManager.PreferMultiSampling = true; GraphicsDeviceManager.ApplyChanges(); DefaultUIFont = Content.Load<SpriteFont>("DefaultUIFont"); _oneByOneTexture = Content.Load<Texture2D>("OneByOne"); _ball = new Ball(this); _ball.Start(); _ball.OnDie += new Ball.OnDieEvent(OnBallDie); Components.Add(_ball); _pad = new Pad(this); Components.Add(_pad); _entities.Add(_ball); _entities.Add(_pad); var levelBricks = _level.Load(IncreaseScore); _entities.AddRange(levelBricks); }
protected override void Initialize() { _spriteBatch = new SpriteBatch(GraphicsDevice); Window.Title = Config.Game.Title; Width = _deviceManager.PreferredBackBufferWidth = Config.Game.Width; Height = _deviceManager.PreferredBackBufferHeight = Config.Game.Height; _deviceManager.ApplyChanges(); _totalScore = _levelScore = 0; _currentLevel = 1; _lives = Config.Game.InitialLives; _livesFormat = Config.UI.LivesFormat; _scoreFormat = Config.UI.ScoreFormat; _levelFormat = Config.UI.LevelFormat; Balls = new Collection<Ball>(); var aBall = new Ball(this); Components.Add(aBall); Balls.Add(aBall); aBall = null; Level = new Level(this); Components.Add(Level); Level.OnBrickDie = IncreaseScore; Pad = new Pad(this); Components.Add(Pad); _previousKeyboardState = Keyboard.GetState(); base.Initialize(); }