コード例 #1
0
        // Main draw method
        public void Draw(SpriteBatch spriteBatch)
        {
            // Don't draw matched blocks (!!TEMP!!)
            if (isMatched)
            {
                return;
            }

            if (type != BlockType.Empty)
            {
                // Create a point for the "actual" position of the tile
                Point actualPosition = new Point(
                    ScaleHelper.ScaleWidth((int)position.X),
                    (int)position.Y);

                // Create a point for the "actual" scale of the tile
                Point actualScale = ScaleHelper.ScalePoint(new Point(BlockWidth, BlockHeight));

                // Draw the tile
                spriteBatch.Draw(TileTexture, new Rectangle(actualPosition, actualScale), Color.White);

                // Calculate the "actual" position of the symbol (add 1/4 of the block height)
                actualPosition.X += (int)Math.Ceiling((float)actualScale.X / 4);
                actualPosition.Y += (int)Math.Ceiling((float)actualScale.Y / 4);

                // Calculate the scale of the symbol (half of that of the block)
                actualScale.X /= 2;
                actualScale.Y /= 2;

                // Draw the symbol
                spriteBatch.Draw(SymbolTexture, new Rectangle(actualPosition, actualScale), Color.White);
            }
        }
コード例 #2
0
        // Main draw method
        public void Draw(SpriteBatch spriteBatch)
        {
            if (type == BlockType.Empty)
            {
                return; // Never draw empty blocks
            }
            if (drawThisFrame)
            {
                // Create a point for the "actual" position of the tile
                Point drawPosition = new Point(
                    ScaleHelper.ScaleWidth((int)position.X),
                    (int)position.Y);

                // Create a point for the "actual" scale of the tile
                Point drawScale = ScaleHelper.ScalePoint(new Point(BlockWidth, BlockHeight));

                // Draw the tile
                spriteBatch.Draw(TileTexture, new Rectangle(drawPosition, drawScale), drawColor);

                // Calculate the "actual" position of the symbol (add 1/4 of the block height)
                drawPosition.X += (int)Math.Ceiling((float)drawScale.X / 4);
                drawPosition.Y += (int)Math.Ceiling((float)drawScale.Y / 4);

                // Calculate the scale of the symbol (half of that of the block)
                drawScale.X /= 2;
                drawScale.Y /= 2;

                // Draw the symbol
                spriteBatch.Draw(SymbolTexture, new Rectangle(drawPosition, drawScale), drawColor);
            }
        }