public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { BackgroundScrollable backgroundScrollable = (BackgroundScrollable)this.background; backgroundScrollable.Draw(gameTime, spriteBatch); spriteBatch.DrawString(game.arialFont, "Visited:" + visited / listPlanets.Count, Vector2.Zero, Color.Red); Rectangle currRectangle; Animation animation; Point topLeftBG = backgroundScrollable.GetTopLeftCoordinate(); foreach (Planet planet in listPlanets) { animation = planet.animation; currRectangle = new Rectangle(planet.centerX - animation.displayWidth / 2, planet.centerY - animation.displayHeight / 2, animation.displayWidth, animation.displayHeight); if (backgroundScrollable.IsRectangleWithinVisibility(currRectangle)) { planet.Draw(gameTime, spriteBatch, (int)topLeftBG.X, (int)topLeftBG.Y, backgroundScrollable.scale); if (planet.Intersects(rocket, topLeftBG.X, topLeftBG.Y, backgroundScrollable.scale)) { buttonEnterPlanet.Draw(gameTime, spriteBatch); } } } rocket.Draw(gameTime, spriteBatch); }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { BackgroundScrollable backgroundScrollable = (BackgroundScrollable)this.background; backgroundScrollable.Draw(gameTime, spriteBatch); rocket.Draw(gameTime, spriteBatch); Rectangle currRectangle; Animation animation; Point topLeftBG = backgroundScrollable.GetTopLeftCoordinate(); foreach (Planet planet in listPlanets) { animation = planet.animation; currRectangle = new Rectangle(planet.centerX - animation.displayWidth / 2, planet.centerY - animation.displayHeight / 2, animation.displayWidth, animation.displayHeight); if (backgroundScrollable.IsRectangleWithinVisibility(currRectangle)) { planet.Draw(gameTime, spriteBatch, (int)topLeftBG.X, (int)topLeftBG.Y, backgroundScrollable.scale); } } }