/// <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); // Ask graphics device about screen bounds we are using. var screenBounds = GraphicsDevice.Viewport.Bounds; // Load paddle texture using Content.Load static method Texture2D paddleTexture = Content.Load<Texture2D>("paddle"); // Create bottom and top paddles and set their initial position PaddleBottom = new Paddle(paddleTexture); PaddleTop = new Paddle(paddleTexture); // Position both paddles with help screenBounds object PaddleBottom.Position = new Vector2(screenBounds.Bottom - PaddleBottom.Size.Height); System.Console.WriteLine(PaddleBottom.Size.Y); PaddleTop.Position = new Vector2(screenBounds.Top); // Load ball texture Texture2D ballTexture = Content.Load<Texture2D>("ball"); // Create new ball object and set its initial position Ball = new Ball(ballTexture); Ball.Position = screenBounds.Center.ToVector2(); // Load background texture and create a new background object Texture2D backgroundTexture = Content.Load<Texture2D>("background"); Background = new Background(backgroundTexture, screenBounds.Width, screenBounds.Height); // Load sounds HitSound = Content.Load<SoundEffect>("hit"); Music = Content.Load<Song>("music"); MediaPlayer.IsRepeating = true; // Start playing background music MediaPlayer.Play(Music); SpritesForDrawList.Add(Background); SpritesForDrawList.Add(PaddleBottom); SpritesForDrawList.Add(PaddleTop); SpritesForDrawList.Add(Ball); }
//update metod som checkar vilken av bakgrunderna som man tryckt ned på och alltså "stänger av" menyskärmen #region public void Update(Background backGround1, Background backGround2, Background backGround3, Background backGround4, Background backGround5) { if (backGround1.Intersect == true || backGround2.Intersect == true || backGround3.Intersect == true || backGround4.Intersect == true || backGround5.Intersect == true) { gameState = false; } }