Beispiel #1
0
        public void DrawShape(SpriteBatch spriteBatch, BaseShape shape, Vector2 position, float scale)
        {
            Vector2 ghostPos = GhostPosition(shape);

            Block[,] blocks = shape.Rotations[(int)shape.Direction];
            for (int row = 0; row <= blocks.GetUpperBound(0); row++)
            {
                for (int col = 0; col <= blocks.GetUpperBound(1); col++)
                {
                    Block block = blocks[row, col];
                    if (block != null)
                    {
                        // Ghost shape
                        if (Screen.Player.GhostShapeEnabled && shape.Equals(Player.Shape))
                        {
                            Vector2 ghostBlockPos = new Vector2(
                                position.X + (block.BoardPosition.X * TetrisGame.BlockSize) * scale,
                                position.Y + (ghostPos.Y + block.Position.Y) * TetrisGame.BlockSize * scale);

                            spriteBatch.Draw(Screen.BlockTexture,
                                             ghostBlockPos,
                                             null,
                                             Color.Gray,
                                             0f,
                                             Vector2.Zero,
                                             scale,
                                             SpriteEffects.None,
                                             0f);
                        }

                        spriteBatch.Draw(Screen.BlockTexture,
                                         new Vector2(
                                             position.X + (block.BoardPosition.X * TetrisGame.BlockSize) * scale,
                                             position.Y + (block.BoardPosition.Y * TetrisGame.BlockSize) * scale),
                                         null,
                                         block.Color,
                                         0f,
                                         Vector2.Zero,
                                         scale,
                                         SpriteEffects.None,
                                         0f);
                    }
                }
            }
        }