Terrarium.Renderer.DirectX.DirectDrawSpriteSurface.GrabSprite C# (CSharp) Method

GrabSprite() public method

Grab a sprite given the x,y frame offset
public GrabSprite ( int xFrame, int yFrame ) : RECT
xFrame int Retrieve the Xth horizontal frame.
yFrame int Retrieve the Yth vertical frame.
return RECT
        public RECT GrabSprite(int xFrame, int yFrame)
        {
            #if TRACE
            GraphicsEngine.Profiler.Start("DirectDrawSpriteSurface.GrabSprite(int, int)");
            #endif
            if (xFrame < 0 || xFrame >= animationFrames ||
                yFrame < 0 || yFrame >= animationTypes)
            {
                throw new Exception("Sprite request is out of range");
            }

            var spriteRect = new RECT();
            spriteRect.Top = yFrame*frameHeight;
            spriteRect.Bottom = spriteRect.Top;
            spriteRect.Bottom += frameHeight;

            spriteRect.Left = xFrame*frameWidth;
            spriteRect.Right = spriteRect.Left;
            spriteRect.Right += frameWidth;

            #if TRACE
            GraphicsEngine.Profiler.End("DirectDrawSpriteSurface.GrabSprite(int, int)");
            #endif
            return spriteRect;
        }

Same methods

DirectDrawSpriteSurface::GrabSprite ( int xFrame, int yFrame, Rectangle dest, Rectangle bounds ) : DirectDrawClippedRect
DirectDrawSpriteSurface::GrabSprite ( int xFrame, int yFrame, Rectangle dest, Rectangle bounds, int factor ) : DirectDrawClippedRect