Beispiel #1
0
 public bool CollidesWith(PlayerSprite player)
 {
     foreach (AsteroidSprite asteroid in Asteroids)
     {
         if (player.BoundingBox.Intersects(asteroid.BoundingBox))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        /// <summary>
        /// Load all the images needed for the background
        /// the spaceship and the asteroids
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            shipTexture2D = Content.Load <Texture2D>("ship");

            playerSprite          = new PlayerSprite(GameAreaWidth / 2, GameAreaHeight / 2);
            playerSprite.Image    = shipTexture2D;
            playerSprite.Boundary = gameArea;

            asteroidTexture2D = Content.Load <Texture2D>("asteroid");

            asteroidsController =
                new AsteroidsController(gameArea, asteroidTexture2D);

            backgroundTexture2D = Content.Load <Texture2D>("space");

            gameFont = Content.Load <SpriteFont>("spaceFont");
            timeFont = Content.Load <SpriteFont>("timerFont");
        }