public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); if (gameState == GameState.Playing) { grid.Draw(gameTime, spriteBatch); tetrisBlock.Draw(gameTime, spriteBatch); drawBlock.Draw(gameTime, spriteBatch); spriteBatch.DrawString(font, "Score = " + score, new Vector2(350, 275), Color.Black); spriteBatch.DrawString(font, "Rows till next level = " + rowsToGo, new Vector2(350, 250), Color.Black); spriteBatch.DrawString(font, "Level = " + level, new Vector2(350, 300), Color.Black); spriteBatch.Draw(controls, new Vector2(600, 0), Color.White); } else if (gameState == GameState.Init) { spriteBatch.Draw(background, Vector2.Zero, Color.White); spriteBatch.Draw(emptyCell, mousePos, Color.Red); } else { spriteBatch.Draw(endScreen, Vector2.Zero, Color.White); spriteBatch.DrawString(menuFont, "Score = " + score, new Vector2(180, 300), Color.Black); spriteBatch.DrawString(menuFont, "Level = " + level, new Vector2(680, 300), Color.Black); } spriteBatch.End(); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); if (gameState == GameState.Menu) { spriteBatch.Draw(logo, new Vector2(TetrisGame.ScreenSize.X / 3 - 10, 30), Color.White); spriteBatch.DrawString(font, "Press SPACE To Start Game", new Vector2(TetrisGame.ScreenSize.X / 3, TetrisGame.ScreenSize.Y / 2), Color.Black); } else if (gameState == GameState.Playing) { grid.Draw(gameTime, spriteBatch); tetrisblock.Draw(gameTime, spriteBatch); nextTetrisBlock.Draw(gameTime, spriteBatch); spriteBatch.DrawString(font, "Score: " + Score, new Vector2(TetrisGame.ScreenSize.X / 2, 0), Color.Black); spriteBatch.DrawString(font, "Level: " + level, new Vector2(TetrisGame.ScreenSize.X - (TetrisGame.ScreenSize.X / 3), 0), Color.Black); if (leveltimer + 1 > gameTime.TotalGameTime.Seconds && leveltimer != 0) { spriteBatch.DrawString(font, "LEVEL UP!", new Vector2(TetrisGame.ScreenSize.X / 2, 320), Color.Black); } } else if (gameState == GameState.GameOver) { spriteBatch.DrawString(font, "GAME OVER", new Vector2(TetrisGame.ScreenSize.X / 3 + 75, TetrisGame.ScreenSize.Y / 2), Color.Blue); spriteBatch.DrawString(font, "Press SPACE To Try Again", new Vector2(TetrisGame.ScreenSize.X / 4 + 75, TetrisGame.ScreenSize.Y / 2 + 50), Color.Blue); Reset(); } spriteBatch.End(); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); grid.Draw(gameTime, spriteBatch); useBlock.Draw(gameTime, spriteBatch); previewBlock.Draw(gameTime, spriteBatch); spriteBatch.DrawString(font, "Score:" + (int)score, new Vector2(360, 5), Color.Blue); spriteBatch.End(); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, string BadBlockKey, string EzBlockKey, string BombKey) { base.Draw(gameTime, spriteBatch); //Draws the different information in the sidebar spriteBatch.DrawString(GameWorld.font, BadBlockKey + ": send bad block", new Vector2(320 + MyGrid.BeginPosition.X, 220 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "to the enemy", new Vector2(320 + MyGrid.BeginPosition.X, 235 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "Cost: 90", new Vector2(320 + MyGrid.BeginPosition.X, 250 + MyGrid.BeginPosition.Y), Color.Blue); BadBlockExample.Draw(gameTime, spriteBatch); spriteBatch.DrawString(GameWorld.font, EzBlockKey + ": Next block", new Vector2(320 + MyGrid.BeginPosition.X, 370 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "becomes this", new Vector2(320 + MyGrid.BeginPosition.X, 385 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "1x1 block", new Vector2(320 + MyGrid.BeginPosition.X, 400 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "Cost: 60", new Vector2(320 + MyGrid.BeginPosition.X, 415 + MyGrid.BeginPosition.Y), Color.Blue); DotExample.Draw(gameTime, spriteBatch); spriteBatch.DrawString(GameWorld.font, BombKey + ": Next block", new Vector2(320 + MyGrid.BeginPosition.X, 485 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "becomes a bomb. ", new Vector2(320 + MyGrid.BeginPosition.X, 500 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "Explodes in", new Vector2(320 + MyGrid.BeginPosition.X, 515 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "a 3x3 area", new Vector2(320 + MyGrid.BeginPosition.X, 530 + MyGrid.BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "Cost: 150", new Vector2(320 + MyGrid.BeginPosition.X, 545 + MyGrid.BeginPosition.Y), Color.Blue); BombExample.Draw(gameTime, spriteBatch); }
/// <summary> /// Draws the grid on the screen. /// </summary> /// <param name="gameTime">An object with information about the time that has passed in the game.</param> /// <param name="spriteBatch">The SpriteBatch used for drawing sprites and text.</param> public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { Vector2 position = BeginPosition; //Draws the colored blocks and the background grid for (int i = 0; i < Width; i++) { for (int f = 0; f < Height; f++) { spriteBatch.Draw(emptyCell, position, grid[i + 2, f]); //The array is 2 larger to the left and to the right, but the grid starts at 0, this is corrected by moving the grid 2 to the right, or x+2 position.Y += 30; } position.Y = 0; position.X += 30; } GhostBlock.Draw(gameTime, spriteBatch); Block.Draw(gameTime, spriteBatch); NextBlock.Draw(gameTime, spriteBatch); spriteBatch.DrawString(GameWorld.font, "Next Block : ", new Vector2(320 + BeginPosition.X, 5 + BeginPosition.Y), Color.Blue); spriteBatch.DrawString(GameWorld.font, "Score : " + Score.ToString(), new Vector2(320 + BeginPosition.X, 155 + BeginPosition.Y), Color.Blue); //Draws the players score spriteBatch.DrawString(GameWorld.font, "Level : " + level.ToString(), new Vector2(320 + BeginPosition.X, 175 + BeginPosition.Y), Color.Blue); //Draws the players level }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); switch (gameState) { case GameState.Start: spriteBatch.DrawString(font, "Startscherm", new Vector2(97, 0), Color.Blue); break; case GameState.Playing: drawGame(); break; case GameState.GameMenu: drawGame(); break; case GameState.GameOver: spriteBatch.DrawString(font, "Game Over", new Vector2(97, 4), Color.Blue); spriteBatch.DrawString(font, "Level = " + level, new Vector2(97, 34), Color.Blue); spriteBatch.DrawString(font, "Score = " + score, new Vector2(97, 64), Color.Blue); break; } spriteBatch.End(); void drawGame() { grid.Draw(gameTime, spriteBatch); activeBlock.Draw(gameTime, spriteBatch, Vector2.Zero); queuedBlock.Draw(gameTime, spriteBatch, new Vector2(400, 100)); spriteBatch.DrawString(font, "Score: " + score, new Vector2(500, 0), Color.Blue); spriteBatch.DrawString(font, "Level: " + level, new Vector2(500, 40), Color.Blue); } }