Public Group

# Scrolling to the left problem - last hope (SOLVED)

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

## Recommended Posts

I've been trying to get my bitmap to scroll left ALL day, almost 12 hours and I still can't do it. I can get it to scoll right ok...but LEFT, oh no. This is my last hope. I've got an image that is 3909 pixels wide...scrolling right I check the amount I've scroll (I increase the scroll width with each iteration of the game loop and that works fine...the code for that is at bottom of the post. Seeing as this works I thought I'd base the scrolling left function on teh same code...but I just can't get it to work. mScrollWCnt increase or decrease by 10 depending if we are moving right (increase) or left (decrease). If it gets <= 0 then mImg->w (3909) is added to it. mScrWidth = 800. The code is:
void SiSEScrollImg::mScrollLeft()
{
// Scroll left

std::cout << "mScrollWCnt " << mScrollWCnt << std::endl;
std::cout << "mImg->w " << mImg->w << std::endl;
std::cout << "mScrWidth " << mScrWidth << std::endl;
std::cout << "mImg->w-mScrWidth " << mImg->w-mScrWidth << std::endl;
std::cout << "mOffSet " << mOffSet << std::endl;

if (mImg->w-mScrollWCnt > mImg->w-mScrWidth)
{
/*
if (mDoOffSet)
{
mOffSet = (int)mScrollWCnt;
mDoOffSet = false;
}

std::cout << "Drawing 2 images" << std::endl;
std::cout << "x position " << (int)(mOffSet+((mImg->w-mScrollWCnt)-(mImg->w-mOffSet))) << std::endl;

*/
mDrawImg(mImg,
(int)(mXPos-mScrollWCnt),
mYPos,
mImg->w,
mImg->h);
/*

mDrawImg(mImg,
(int)(mOffSet+((mImg->w-mScrollWCnt)-(mImg->w-mOffSet))),
mYPos,
(int)(mImg->w-mScrollWCnt),
mImg->h,
(int)mScrollWCnt,
(int)mScrollHCnt);     // destY

mDrawImg(mImg,                                      // srcSurface
mXPos,              // srcX
mYPos,                                     // srcY
(int)(mImg->w-(mOffSet+((mImg->w-mScrollWCnt)-(mImg->w-mOffSet)))),
mImg->h,
(int)mScrollWCnt,
(int)mScrollHCnt);                     // destY
*/

}
else
{
std::cout << "Drawing 1 image" << std::endl;

mDrawImg(mImg,                  // srcSurface
mXPos,                 // srcX
mYPos,                 // srcY
mImg->w,               // width
mImg->h,               // height
(int)mScrollWCnt,      // destX
(int)mScrollHCnt);     // destY

/*

mDoOffSet = true;
*/
}

return;


Right scroll (THIS IS OKAY - it works)
void SiSEScrollImg::mScrollRight()
{
// Scroll right
if (mScrollWCnt > mImg->w-mScrWidth)
{

std::cout << "Drawing 2" << std::endl;
mDrawImg(mImg,                                  // srcSurface
mXPos,                                 // srcX
mYPos,                                 // srcY
(int)(mImg->w-mScrollWCnt),            // width
mImg->h,                               // height
(int)mScrollWCnt,                      // destX
(int)mScrollHCnt);                     // destY

mDrawImg(mImg,                                      // srcSurface
(int)(mImg->w-mScrollWCnt-1),              // srcX
mYPos,                                     // srcY
(int)(mScrWidth-(mImg->w-mScrollWCnt)),    // width
mImg->h);                                  // height

}
else
{
std::cout << "Drawing 1" << std::endl;
mDrawImg(mImg,                  // srcSurface
mXPos,                 // srcX
mYPos,                 // srcY
mImg->w,               // width
mImg->h,               // height
(int)mScrollWCnt,      // destX
0);     // destY
}

return;
}


As you can see I've tried quite a lot of stuff. It seems to work initially but then the drawn pixels dissapear and the image starts afresh from teh left of the screen. What am I doing. If you need more info please let me know. PLEASE HELP!!! Before I go completely bonkers. [Edited by - garyfletcher on May 28, 2005 9:08:03 AM]

##### Share on other sites
Oh well...thanks for the help guys..:)

##### Share on other sites
Correct me if I'm wrong, but it looks like the mScrollRight is only responsible for repeating the image when the edge is visible? If that is the case, why is it neccessary to have an mScrollRight and mScrollLeft function instead of just an mScroll function (literally just rename mScrollRight to mScroll)?

If you need the mScrollRight/Left functions you can just copy/paste the code from mScrollRight to mScrollLeft and it should work...or at least I can't see why it wouldn't.

##### Share on other sites
MrP

You're completley right...the mScrollRight() function will do right AND left scrolling...man, all that fustration for nothing...how stupid of me. Thanks for spoting that..:)

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632998
• Total Posts
3009808
• ### Who's Online (See full list)

There are no registered users currently online

×