/// <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.Black); // TODO: Add your drawing code here spriteBatch.Begin(); if (win) { winner.Draw(spriteBatch); Vector2 messageCentered = scoreFont.MeasureString("Thanks For Playing!") / 2; spriteBatch.DrawString(scoreFont, "Thanks For Playing!", new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - messageCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2)), Color.Red); Vector2 fontCentered = scoreFont.MeasureString("Score: " + winner_score.ToString()) / 2; spriteBatch.DrawString(scoreFont, "Score: " + winner_score.ToString(), new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - fontCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2) + 100), Color.Black); } else if (game_over) { gameOver.Draw(spriteBatch); Vector2 fontCentered = scoreFont.MeasureString("Score: " + game_over_score.ToString()) / 2; spriteBatch.DrawString(scoreFont, "Score: " + game_over_score.ToString(), new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - fontCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2) + 100), Color.Black); } else { current_maze.Draw(spriteBatch); // render the score in the top left of the screen spriteBatch.DrawString(scoreFont, $"Score: {score}", Vector2.Zero, Color.Black); player.Draw(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); }
void DrawTransitionOld(Maze maze, float translationX) { Matrix t = Matrix.CreateTranslation(-translationX, 0, 0); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, t); maze.Draw(spriteBatch); spriteBatch.End(); }
void DrawTransitionNew(Maze maze, float translationX) { Matrix t = Matrix.CreateTranslation(graphics.GraphicsDevice.Viewport.Width - translationX, 0, 0); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, t); maze.Draw(spriteBatch); player.Draw(spriteBatch); spriteBatch.End(); }
/// <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.Black); // TODO: Add your drawing code here switch (viewState) { case ViewState.IDLE: spriteBatch.Begin(); if (win) { winner.Draw(spriteBatch); Vector2 messageCentered = scoreFont.MeasureString("Thanks For Playing!") / 2; spriteBatch.DrawString(scoreFont, "Thanks For Playing!", new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - messageCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2)), Color.Red); Vector2 fontCentered = scoreFont.MeasureString("Score: " + winner_score.ToString()) / 2; spriteBatch.DrawString(scoreFont, "Score: " + winner_score.ToString(), new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - fontCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2) + 100), Color.Black); } else if (game_over) { gameOver.Draw(spriteBatch); Vector2 fontCentered = scoreFont.MeasureString("Score: " + game_over_score.ToString()) / 2; spriteBatch.DrawString(scoreFont, "Score: " + game_over_score.ToString(), new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - fontCentered.X, (graphics.GraphicsDevice.Viewport.Height / 2) + 100), Color.Black); } else { current_maze.Draw(spriteBatch); // render the score in the top left of the screen spriteBatch.DrawString(scoreFont, $"Score: {score}", Vector2.Zero, Color.Black); player.Draw(spriteBatch); wallParticleSystem.Draw(); } spriteBatch.End(); break; case ViewState.TRANSITION_RIGHT: DrawTransitionOld(prev_maze, translationX); DrawTransitionNew(current_maze, translationX); Debug.WriteLine($"{-translationX} , {graphics.GraphicsDevice.Viewport.Width - translationX}"); //float timer = 0F; //while(timer < 1000000) //{ // timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; //} if (translationX == graphics.GraphicsDevice.Viewport.Width - 1) { Debug.WriteLine("One More"); } translationX++; if (translationX >= graphics.GraphicsDevice.Viewport.Width) { viewState = ViewState.IDLE; translationX = 0; } break; } base.Draw(gameTime); }