/// <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) { switch (state) { case GameState.Game: GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here spriteBatch.Begin(); chess.draw(ref spriteBatch); Player.checkColor(ref spriteBatch, ref graphics, ref chess); player1.selectionUpdate(ref spriteBatch, ref graphics, ref chess); player2.selectionUpdate(ref spriteBatch, ref graphics, ref chess); //Player.showAttackedTiles(ref spriteBatch, ref graphics, ref chess); chess.drawPieces(ref spriteBatch); chess.drawTurnInformation(ref spriteBatch); spriteBatch.End(); break; case GameState.StartMenu: GraphicsDevice.Clear(Color.White); spriteBatch.Begin(); StartMenu.drawStartMenu(ref spriteBatch, ref graphics); spriteBatch.End(); break; } base.Draw(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here chess.loadTexture(Content); chess.setPieces(Content); StartMenu.loadStartMenu(); chess.loadTurnInformation(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { switch (state) { case GameState.StartMenu: StartMenu.clickOnStartGame(Mouse.GetState()); StartMenu.clickOnExitGame(Mouse.GetState()); break; case GameState.Game: player1.attemptsToMove(Mouse.GetState(), ref chess); player2.attemptsToMove(Mouse.GetState(), ref chess); player1.clicksOnPiece(Mouse.GetState(), ref chess); player2.clicksOnPiece(Mouse.GetState(), ref chess); if (player1.Checkmate) { delayTime += gameTime.ElapsedGameTime.TotalSeconds; if (delayTime >= 0.5) { System.Windows.Forms.MessageBox.Show("Black player wins by checkmate"); this.Exit(); } } else if (player2.Checkmate) { delayTime += gameTime.ElapsedGameTime.TotalSeconds; if (delayTime >= 0.5) { System.Windows.Forms.MessageBox.Show("White player wins by checkmate"); this.Exit(); } } break; } // TODO: Add your update logic here base.Update(gameTime); }