Time for action – Game1 declarations
Double click on the
Game1.cs
file in Solution Explorer to reactivate the Game1.cs code file window.Add the following declarations to the Game1 class member declaration area:
GameBoard gameBoard; Vector2 gameBoardDisplayOrigin = new Vector2(70, 89); int playerScore = 0; enum GameStates { TitleScreen, Playing }; GameStates gameState = GameStates.TitleScreen; Rectangle EmptyPiece = new Rectangle(1, 247, 40, 40); const float MinTimeSinceLastInput = 0.25f; float timeSinceLastInput = 0.0f;
What just happened?
The gameBoard
instance of GameBoard will hold all of the playing pieces, while the gameBoardDisplayOrigin
vector points to where on the screen the board will be drawn. Using a vector like this makes it easy to move the board in the event that you wish to change the layout of your game screen.
As we did in SquareChase, we store the player's score and will display it in the window title bar.
In order to implement a simple game state mechanism, we define...