Time for action – implementing game states
Add declarations to the
Game1
class for ourGameState
enum:Private Enum GameState TitleScreen Playing PlayerDead GameOver End Enum Private _gameState As GameState = GameState.TitleScreen
Still in the declaration section of the
Game1
class, add vectors for the display position of our text items, a texture to hold the title screen image, and the delay before respawn when the player dies:Private gameOverPosition As Vector2 = New Vector2(350, 300) Private livesPosition As Vector2 = New Vector2(600, 580) Private titleScreen As Texture2D Private deathTimer As Single = 0 Private deathDelay As Single = 5
We currently have temporary code in the
LoadContent()
method that loads straight into the first level of the game. Replace the currentLoadContent()
method with the following code:Protected Overrides Sub LoadContent() spriteBatch = New SpriteBatch(GraphicsDevice) TileMap.Initialize( Content.Load(Of Texture2D)("Textures...