Archived

This topic is now archived and is closed to further replies.

problems with IDirectDrawSurface7 pointer

This topic is 5750 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Wasup. I have a Sprite class which holds a pointer to an IDirectDrawSurface7 which is where the sprite frames are. When I create a new sprite, I pass in a bunch of stuff including what surface the frames reside in. Well, when I go to draw (blt) the current frame, nothing happens. And yes I am calling flip. anyway, here is the constructor and the Draw function:
    
Sprite::Sprite( IDirectDrawSurface7 *p_surfaceDest, 
			    LONG p_x,
				LONG p_y,
				DWORD p_cx,
				DWORD p_cy,
				LONG p_dx,
				LONG p_dy,
				int p_nFrames,
				bool p_used	) :
				
					m_pDDS( p_surfaceDest ),
					m_x( p_x ),
					m_y( p_y ),
					m_cx( p_cx ),
					m_cy( p_cy ),
					m_dx( p_dx ),
					m_dy( p_dy ),
					m_numFrames( p_nFrames ),
					m_used( p_used ),					
					m_frame( 0 ),
					m_dwMsecBasis( 20 ),
					m_dwTimeLastMoveX( 0 ),
					m_dwTimeLastMoveY( 0 ),					
					dwRemainderX( 0 ),
					dwRemainderY( 0 )
{
	
}
  

      
void Sprite::Draw( IDirectDrawSurface7 *pDDSDest )
{
	RECT rectSrc;
	RECT rectDst;

    rectSrc.left = 0;
    rectSrc.top = m_frame * m_cy;
    rectSrc.right = m_cx;
    rectSrc.bottom = rectSrc.top + m_cy;

    rectDst.left = m_x;
    rectDst.top = m_y;
    rectDst.right = rectDst.left + m_cx;
    rectDst.bottom = rectDst.top + m_cy;

	// diy clipping

	if ( m_x < 0 )
	{
		m_dx *= -1;
	}
	else if ( m_x + m_cx > SCREEN_WIDTH )
	{
		m_dx *= -1;
	}
	
	if ( m_y < 0 )
	{	
		m_dy *= -1;
	}
	else if ( m_y + m_cy > SCREEN_HEIGHT )
	{
		m_dy *= -1;
	}
	
	pDDSDest->Blt( &rectDst, m_pDDS, &rectSrc, DDBLT_KEYSRC | DDBLT_WAIT, NULL );
}
    
I believe it has something to do with m_pDDS, not sure tho. Anyone have a guess? edit - just to clarify about when I call Flip, it's in my DrawFrame function which is in my peek message loop. Edited by - randomDecay on March 19, 2002 12:25:18 PM

Share this post


Link to post
Share on other sites