/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.White); // TODO: Add your drawing code here spriteBatch.Begin(); spriteBatch.Draw(background, mainFrame, Color.White); player1.Draw(spriteBatch); for (int i = 0; i < Floor.Length; i++) { Floor[i].Draw(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // Calculate and apply the world/view transform worldOffset = new Vector2(100, 0) - new Vector2(player.position.X, 0); var t = Matrix.CreateTranslation(worldOffset.X, worldOffset.Y, 0); // Begin Drawing spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, t); backgroundFlyweight.Draw(spriteBatch); enemyFlyweight.Draw(spriteBatch); bubbleFlyweight.Draw(spriteBatch); player.Draw(spriteBatch); spriteBatch.DrawString(scoreFont, helpText + (gameStarted ? score.ToString() : ""), new Vector2(scorePosition.X - 2, scorePosition.Y) - worldOffset, Color.Black); spriteBatch.DrawString(scoreFont, helpText + (gameStarted ? score.ToString() : ""), scorePosition - worldOffset, Color.White); // End Drawing spriteBatch.End(); base.Draw(gameTime); }