public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); spriteBatch.Draw(background, destinationRectangle: new Rectangle(0, 0, 600, 900), color: Color.White * 0.05f); spriteBatch.Draw(PlayButtonTexture, destinationRectangle: new Rectangle(0, 0, 600, 900), color: PlayButtonColor); spriteBatch.Draw(ExitButtonTexture, destinationRectangle: new Rectangle(0, 0, 600, 900), color: ExitButtonColor); spriteBatch.DrawString(font, Score.getScore().ToString(), new Vector2(GraphicsDevice.Viewport.Width / 2 - font.MeasureString(Score.getScore().ToString()).X / 2, 360), new Color(176, 47, 31)); spriteBatch.End(); }
/// <summary> /// Increases the game difficulty depending on current score /// </summary> private void MakeHarder(TimeSpan timer2, TimeSpan timer3, int lvl) { if (Score.getScore() >= lvl * 3000) { lvl++; } TimeSpan milis = new TimeSpan(0, 0, 0, 0, 1000); for (int i = 0; i < lvl; i++) { timer2 = milis.Subtract(timer3); } }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); spriteBatch.Draw(background, destinationRectangle: new Rectangle(0, 0, 600, 900), color: Color.Silver); for (float x = -cols; x < cols; x++) { Rectangle rectangle = new Rectangle((int)(centerX + x * gridSize), shiftY, 1, height); spriteBatch.Draw(texture1px, rectangle, Color.SteelBlue); } for (float y = -rows; y < rows; y++) { Rectangle rectangle = new Rectangle(shiftX, (int)(centerY + y * gridSize), width, 1); spriteBatch.Draw(texture1px, rectangle, Color.SteelBlue); } spriteBatch.DrawString(font, "SCORE", new Vector2(scorePos - font.MeasureString("SCORE").X / 2, 520), Color.White); spriteBatch.DrawString(font, Score.getScore().ToString(), new Vector2(scorePos - font.MeasureString(Score.getScore().ToString()).X / 2, 560), Color.White); for (int i = 0; i < 4; i++) { DrawRectangle(spriteBatch, new Rectangle((board.GetFigure()[i].position.Y * 40 + shiftX + 1), ((board.GetFigure()[i].position.X - 1) * 40 + shiftY), 39, 39), board.GetFigure()[i].Color); } for (int i = 0; i < board.GetWidth(); i++) { for (int j = 0; j < board.GeHeight(); j++) { if (board[j, i] != null) { DrawRectangle(spriteBatch, new Rectangle((i * 40 + shiftX + 1), ((j - 1) * 40 + shiftY), 39, 39), board[j, i].Color); } } } DrawNext(spriteBatch, board); spriteBatch.End(); }