• Advertisement

Archived

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

wraparound vertical scrolling

This topic is 5847 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

Hi! I have a large bitmap that I am vertically scrolling (using DX7), and I would like the bitmap to scroll seamlessly when it reaches the bottom of the bitmap. I want it to 'wrap-around' so that when it finishes scrolling, the first part of the bitmap seams in with the bottom. Here is my code, I don't have 'wrap-around code' -- what's here scrolls vertically. I would like to know how to do wraparound code like I mentioned a paragraph above. Thanks
      

// DrawNextFrame() function  

	g_yUpdate += 5;



	RECT rectSrc;
	RECT rectDst;
        //



	rectSrc.left = 0;
	rectSrc.top = 0 + g_yUpdate;
	rectSrc.right = SCREEN_WIDTH;
	rectSrc.bottom = SCREEN_HEIGHT + g_yUpdate;
        //

	rectDst.left = 0;
	rectDst.top = 0;
	rectDst.right = SCREEN_WIDTH;
	rectDst.bottom = SCREEN_HEIGHT;
        //

	g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
        
[edited by - randomDecay on April 19, 2002 1:16:09 PM] [edited by - randomDecay on April 19, 2002 1:17:13 PM]

Share this post


Link to post
Share on other sites
Advertisement
This should work:

// DrawNextFrame() function
g_yUpdate += 5;



RECT rectSrc;
RECT rectDst;
//


rectSrc.left = 0;
rectSrc.top = 0 + g_yUpdate;
rectSrc.right = SCREEN_WIDTH;
rectSrc.bottom = SCREEN_HEIGHT + g_yUpdate;
//
rectDst.left = 0;
rectDst.top = 0;
rectDst.right = SCREEN_WIDTH;
rectDst.bottom = SCREEN_HEIGHT;
//
// BitmapHeight= Total height of your offscreen bitmap

BitmapHeight=??;

if (g_yUpdate>BitmapHeight) g_yUpdate=0;

if (rectSrc.bottom g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
else
{
rectSrc.bottom=BitmapHeight;
rectDst.bottom =BitmapHeight-g_yUpdate;
g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
rectSrc.top = 0;
rectSrc.bottom=rectSrc.bottom-BitmapHeight;
rectDst.top = rectDst.bottom;
rectDst.bottom = SCREEN_HEIGHT;
g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
}



Basically what it is doing is when the Screen runs off the bottom of the large bitmap, I Take the remaining bitmap from the bottom blit it to the screen then add the chunk from the beginning and when your g_yUpdate goes beyond the big bitmap bottom reset it. Hope that made sense. Let me know how it works, it should be fast...only extra baggage is redefining 6 of your RECT variables.

Rob
rhuala@yahoo.com

PS. Remember you have to define the variable Bitmapheight, the total height of your large bitmap (Never changes so should set outside loop).

Share this post


Link to post
Share on other sites
Thanks, but what is this line supposed to be...?

quote:

if (rectSrc.bottom g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );



I''ll let you know if it works once this line is sorted out..

Thanks!

Share this post


Link to post
Share on other sites
oops, I did it off the top of my head u may need to debug a bit should be:

if (rectSrc.bottom g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
else
{
.
.
.

thaats wierd i pasted from notepad and it looks right in my original...

Rob

Share this post


Link to post
Share on other sites
darn it''s not letting me post properly, should have used this from the start:


  
// DrawNextFrame() function

g_yUpdate += 5;



RECT rectSrc;
RECT rectDst;
//



rectSrc.left = 0;
rectSrc.top = 0 + g_yUpdate;
rectSrc.right = SCREEN_WIDTH;
rectSrc.bottom = SCREEN_HEIGHT + g_yUpdate;
//

rectDst.left = 0;
rectDst.top = 0;
rectDst.right = SCREEN_WIDTH;
rectDst.bottom = SCREEN_HEIGHT;
//

// BitmapHeight= Total height of your offscreen bitmap

if (rectSrc.bottom<BitmapHeight)
g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
else
{
rectSrc.bottom=BitmapHeight;
rectDst.bottom =BitmapHeight-g_yUpdate;
g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
rectSrc.top = 0;
rectSrc.bottom=rectSrc.bottom-BitmapHeight;
rectDst.top = rectDst.bottom;
rectDst.bottom = SCREEN_HEIGHT;
g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );
}

if (g_yUpdate>BitmapHeight) g_yUpdate=0;



Share this post


Link to post
Share on other sites
still doesn''t look right...

if (rectSrc.bottom g_DDBackbuffer->Blt( &rectDst, g_DDOffscreenMap, &rectSrc, DDBLT_WAIT, NULL );

...doesn''t make much sense

Share this post


Link to post
Share on other sites
Just debug it, you get the basic concept right... what''s it doing?

Rob

PS: the last posts wouldn''t show anything past the less than sign, I was just too lazy to put the source code tags in

Share this post


Link to post
Share on other sites

  • Advertisement