Game Development Reference
In-Depth Information
public void
Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
spriteBatch.Begin();
Drawthegameworld...
if
(lives <=0)
spriteBatch.Draw(gameover,
new
Vector2(Painter.Screen.X
−
gameover.Width,
−
gameover.Height) / 2,
Painter.Screen.Y
Color.White);
spriteBatch.End();
}
You can see here that we use the dimensions of the screen and the dimensions of the
'game over' overlay to position it nicely in the center of the screen.
9.7 What You Have Learned
In this chapter, you have learned:
•
how to store and display the number of lives that a player currently has;
•
how to repeat a group of instructions using the
while
or
for
instruction;
•
how to restart the game after the player has died.