/// <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.TransparentBlack); var viewMatrix = camera.GetViewMatrix(); var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0f, -1f); // Begin drawing spriteBatch.Begin(transformMatrix: viewMatrix); mapRenderer.Draw(map, ref viewMatrix, ref projectionMatrix); // Call the "Draw" function from our player class player.Draw(spriteBatch); goal.Draw(spriteBatch); unlock.Draw(spriteBatch); foreach (Enemy enemy in enemies) { enemy.Draw(spriteBatch); } // Finish drawing spriteBatch.End(); spriteBatch.Begin(); spriteBatch.DrawString(arialFont, "SCORE: " + score.ToString(), new Vector2(20, 20), Color.White); if (debug == true) { spriteBatch.DrawString(arialFont, "Debug = " + debug.ToString(), new Vector2(20, 40), Color.White); } int loopCount = 0; while (loopCount < lives) { spriteBatch.Draw(heart, new Vector2(GraphicsDevice.Viewport.Width - 60 - loopCount * 40, 20), Color.White); // Heart location loopCount++; } 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) { //Clears anything previously drawn to screen GraphicsDevice.Clear(Color.Black); var viewMatrix = camera.GetViewMatrix(); var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0f, -1f); //Begin drawing spriteBatch.Begin(transformMatrix: viewMatrix); mapRenderer.Draw(map, ref viewMatrix, ref projectionMatrix); //Calls the 'Draw' function from player class player.Draw(spriteBatch); foreach (Enemy enemy in enemies) { enemy.Draw(spriteBatch); } goal.Draw(spriteBatch); //Finish drawing spriteBatch.End(); // Draw all GUI components in a seperate sprite batch spriteBatch.Begin(); spriteBatch.DrawString(arialFont, "Score: " + score.ToString(), new Vector2(20, 20), Color.Yellow); int loopCount = 0; while (loopCount < lives) { spriteBatch.Draw(heart, new Vector2(GraphicsDevice.Viewport.Width - 80 - loopCount * 40, 20), Color.White); loopCount++; } spriteBatch.End(); base.Draw(gameTime); }