Пример #1
0
        private void GameDraw()
        {
            GraphicsDevice.SetRenderTarget(nextRenderer);
            GraphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
            int starting = 1;

            for (int i = 0; i < 5; i++)
            {
                foreach (Vector2 v in nextTetromino[i].StartingPosition())
                {
                    Rectangle kloc = new Rectangle(((int)v.X - 3) * 44, ((int)v.Y + 2) * 44 + (44 * starting), 44, 44);

                    if (nextTetromino[i].PieceSymbol() == 'i')
                    {
                        spriteBatch.Draw(IBlockTex, kloc, Color.White);
                    }
                    if (nextTetromino[i].PieceSymbol() == 'o')
                    {
                        spriteBatch.Draw(OBlockTex, kloc, Color.White);
                    }
                    if (nextTetromino[i].PieceSymbol() == 't')
                    {
                        spriteBatch.Draw(TBlockTex, kloc, Color.White);
                    }
                    if (nextTetromino[i].PieceSymbol() == 's')
                    {
                        spriteBatch.Draw(SBlockTex, kloc, Color.White);
                    }
                    if (nextTetromino[i].PieceSymbol() == 'z')
                    {
                        spriteBatch.Draw(ZBlockTex, kloc, Color.White);
                    }
                    if (nextTetromino[i].PieceSymbol() == 'j')
                    {
                        spriteBatch.Draw(JBlockTex, kloc, Color.White);
                    }
                    if (nextTetromino[i].PieceSymbol() == 'l')
                    {
                        spriteBatch.Draw(LBlockTex, kloc, Color.White);
                    }
                }
                starting += 4;
            }
            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);

            GraphicsDevice.SetRenderTarget(holdRenderer);
            GraphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);


            if (heldTetromino != null)
            {
                foreach (Vector2 v in heldTetromino.StartingPosition())
                {
                    Rectangle kloc = new Rectangle(((int)v.X - 3) * 44, ((int)v.Y + 2) * 44, 44, 44);

                    if (heldTetromino.PieceSymbol() == 'i')
                    {
                        spriteBatch.Draw(IBlockTex, kloc, Color.White);
                    }
                    if (heldTetromino.PieceSymbol() == 'o')
                    {
                        spriteBatch.Draw(OBlockTex, kloc, Color.White);
                    }
                    if (heldTetromino.PieceSymbol() == 't')
                    {
                        spriteBatch.Draw(TBlockTex, kloc, Color.White);
                    }
                    if (heldTetromino.PieceSymbol() == 's')
                    {
                        spriteBatch.Draw(SBlockTex, kloc, Color.White);
                    }
                    if (heldTetromino.PieceSymbol() == 'z')
                    {
                        spriteBatch.Draw(ZBlockTex, kloc, Color.White);
                    }
                    if (heldTetromino.PieceSymbol() == 'j')
                    {
                        spriteBatch.Draw(JBlockTex, kloc, Color.White);
                    }
                    if (heldTetromino.PieceSymbol() == 'l')
                    {
                        spriteBatch.Draw(LBlockTex, kloc, Color.White);
                    }
                }
            }


            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);



            GraphicsDevice.SetRenderTarget(boardRenderer);
            GraphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Rectangle kloc = new Rectangle(j * 44, i * 44, 44, 44);


                    if (board[j, i + 20] == 'i')
                    {
                        spriteBatch.Draw(IBlockTex, kloc, Color.White);
                    }
                    if (board[j, i + 20] == 'o')
                    {
                        spriteBatch.Draw(OBlockTex, kloc, Color.White);
                    }
                    if (board[j, i + 20] == 't')
                    {
                        spriteBatch.Draw(TBlockTex, kloc, Color.White);
                    }
                    if (board[j, i + 20] == 's')
                    {
                        spriteBatch.Draw(SBlockTex, kloc, Color.White);
                    }
                    if (board[j, i + 20] == 'z')
                    {
                        spriteBatch.Draw(ZBlockTex, kloc, Color.White);
                    }
                    if (board[j, i + 20] == 'j')
                    {
                        spriteBatch.Draw(JBlockTex, kloc, Color.White);
                    }
                    if (board[j, i + 20] == 'l')
                    {
                        spriteBatch.Draw(LBlockTex, kloc, Color.White);
                    }
                }
            }
            foreach (Vector2 v in CurrentGhostPositions)
            {
                if (currentTetromino.PieceSymbol() != null)
                {
                    spriteBatch.Draw(GhostTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
            }
            foreach (Vector2 v in CurrentBlockPositions)
            {
                if (currentTetromino.PieceSymbol() == 'i')
                {
                    spriteBatch.Draw(IBlockTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
                if (currentTetromino.PieceSymbol() == 'o')
                {
                    spriteBatch.Draw(OBlockTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
                if (currentTetromino.PieceSymbol() == 't')
                {
                    spriteBatch.Draw(TBlockTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
                if (currentTetromino.PieceSymbol() == 's')
                {
                    spriteBatch.Draw(SBlockTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
                if (currentTetromino.PieceSymbol() == 'z')
                {
                    spriteBatch.Draw(ZBlockTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
                if (currentTetromino.PieceSymbol() == 'j')
                {
                    spriteBatch.Draw(JBlockTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
                if (currentTetromino.PieceSymbol() == 'l')
                {
                    spriteBatch.Draw(LBlockTex, new Rectangle((int)v.X * 44, (int)v.Y * 44, 44, 44), Color.White);
                }
            }

            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);

            GraphicsDevice.SetRenderTarget(themeRenderer);
            GraphicsDevice.Clear(Color.Transparent);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

            spriteBatch.Draw(BackgroundTex, new Rectangle(0, 0, 1920, 1080), Color.White);
            spriteBatch.Draw(GridTex, new Rectangle(480, 0, 960, 1080), Color.White);
            spriteBatch.Draw(boardRenderer, new Rectangle(740, 100, 440, 880), Color.White);
            spriteBatch.Draw(nextRenderer, new Rectangle(1220, 119, 140, 462), Color.White);
            spriteBatch.Draw(holdRenderer, new Rectangle(600, 124, 140, 140), Color.White);
            spriteBatch.Draw(OverlayTex, new Rectangle(480, 0, 960, 1080), Color.White);

            spriteBatch.DrawString(neuro, $"SCORE:", new Vector2(1220, 650), Color.White);
            spriteBatch.DrawString(neuro, $"{score}", new Vector2(1220, 700), Color.White);
            spriteBatch.DrawString(neuro, $"CLEARED LINES:", new Vector2(1220, 775), Color.White);
            spriteBatch.DrawString(neuro, $"{linesCleared}", new Vector2(1220, 825), Color.White);
            spriteBatch.DrawString(neuro, $"LEVEL:", new Vector2(1220, 900), Color.White);
            spriteBatch.DrawString(neuro, $"{level}", new Vector2(1220, 950), Color.White);



            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);



            spriteBatch.Begin();

            spriteBatch.Draw(themeRenderer, GraphicsDevice.Viewport.Bounds, Color.White);

            spriteBatch.End();
        }
Пример #2
0
 public void PlaceBlock()
 {
     foreach (Vector2 v in CurrentBlockPositions)
     {
         if ((int)v.Y < 0 && !CanMove(Directions.Down, CurrentBlockPositions))
         {
             currentGameState = GameStates.End;
             SubmitStats(false);
             break;
         }
         else
         {
             board[(int)v.X, 20 + (int)v.Y] = currentTetromino.PieceSymbol();
         }
     }
 }