/// <summary> /// Draw content. /// </summary> /// <param name="spriteBatch"></param> public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { messageTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; Scrolling1.Draw(spriteBatch); Scrolling2.Draw(spriteBatch); foreach (var sprite in Sprites) { sprite.Draw(gameTime, spriteBatch); } if (IsUpgraded && messageTimer < 3f) { string message = "Ship Upgraded!"; float messagePossitionX = Camera.SCREEN_WIDTH / 2 - FontManager.Instance.Arial.MeasureString(message).X / 2; spriteBatch.DrawString(FontManager.Instance.Arial, message, new Vector2(messagePossitionX, messagePositionY), Color.White); messagePositionY--; } else { IsUpgraded = false; messagePositionY = Camera.SCREEN_HEIGHT / 2; } }
/// <summary> /// Update background images. /// </summary> private void UpdateBackground() { // X is increasing img1 if (Scrolling1.Rectangle.X + Scrolling1.Texture.Width <= Player.Position.X - 330) { Scrolling1.Rectangle.X = Scrolling2.Rectangle.X + Scrolling2.Texture.Width; } // Y is decreasing img1 if (Scrolling1.Rectangle.Y + Scrolling1.Texture.Height <= Player.Position.Y - 200) { Scrolling1.Rectangle.Y = Scrolling2.Rectangle.Y + Scrolling2.Texture.Height; } // X is increasing img2 if (Scrolling2.Rectangle.X + Scrolling2.Texture.Width <= Player.Position.X - 330) { Scrolling2.Rectangle.X = Scrolling1.Rectangle.X + Scrolling1.Texture.Width; } // Y is decreasing img2 if (Scrolling2.Rectangle.Y + Scrolling2.Texture.Height <= Player.Position.Y - 200) { Scrolling2.Rectangle.Y = Scrolling1.Rectangle.Y + Scrolling1.Texture.Height; } // Y is decreasing if (Scrolling1.Rectangle.Y >= Player.Position.Y) { Scrolling1.Rectangle.Y -= 200; Scrolling2.Rectangle.Y -= 200; } // X is decreasing if (Scrolling1.Rectangle.X >= Player.Position.X - 200) { Scrolling1.Rectangle.X -= 200; Scrolling2.Rectangle.X -= 200; } Scrolling1.Update(); Scrolling2.Update(); }