Issue with scrolling that I just can't fix

SGDK only sub forum

Moderator: Stef

Post Reply
POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Issue with scrolling that I just can't fix

Post by POLYGAMe » Sat Feb 13, 2016 2:27 am

So I've checked EVERYTHING and I can't see what's wrong. When I bend my road and leave the sky still, it works properly. My road bends to make a corner and the sky stays still.
Sky not scrolling - road bent.png
Sky not scrolling - road bent.png (16.81 KiB) Viewed 3392 times
When I scroll the sky but don't bend the road, that also works, I get a straight road and a scrolling sky.
Sky scrolling - road straight.png
Sky scrolling - road straight.png (19.4 KiB) Viewed 3392 times
The problem is, when I do both, for no reason the road portion is shifted quite a few tiles to the right and if I look really closely I can see random lines being scrolled every so slightly.
Sky scrolling - road bent.png
Sky scrolling - road bent.png (14.8 KiB) Viewed 3392 times
It makes no sense. All of the function parameters are correct.

Here is the code for the bend road function:

Code: Select all

void BendRoad(u16 ScrollValuesLength, fix32* ScrollValuesFloats, s16* ScrollValues, u16 iVertLine, u16 iLinesToScroll)
{
    u16 uOffset = 0;
    u16 i = 0;

    // ADJUST EACH LINE'S OFFSET (BEND ROAD)
    for (i = ScrollValuesLength - 1; i > 0; i--)
    {
        uOffset += 15;

        ScrollValuesFloats[i] = ScrollValuesFloats[i + 1] + uOffset;
        ScrollValues[i] = fix32ToInt(ScrollValuesFloats[i]);
    }

    // PERFORM LINE SCROLLING FOR ROAD
    VDP_setHorizontalScrollLine(PLAN_B, iVertLine, ScrollValues, iLinesToScroll, FALSE);
}
And here is the code for the scroll sky function:

Code: Select all

void ScrollSky(u16 skyScrollValuesLength, s16* skyScrollValues, u16 iSkyVertLine, u16 iSkyLinesToScroll)
{
    u16 i = 0;

    // SCROLL SKY
    for (i = 0; i < skyScrollValuesLength; i++)
    {
        skyScrollValues[i] -= 1; // TODO - CHANGE TO MATCH SPEED
    }

    // PERFORM LINE SCROLLING FOR SKY
    VDP_setHorizontalScrollLine(PLAN_A, iSkyVertLine, skyScrollValues, iSkyLinesToScroll, FALSE);
}

What could be causing this? Any help would be greatly appreciated as I'm really stuck!

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Re: Issue with scrolling that I just can't fix

Post by r57shell » Sat Feb 13, 2016 7:59 pm

write equations, how much should be scroll on top of road.
and you'll see your bug.
reason is because you're calculating from bottom.
Image

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Issue with scrolling that I just can't fix

Post by POLYGAMe » Sun Feb 14, 2016 3:26 am

r57shell wrote:write equations, how much should be scroll on top of road.
and you'll see your bug.
reason is because you're calculating from bottom.
Each plane is counting in different directions and meeting in the middle. The numbers are correct and even if they weren't I'm controlling the scrolling of the planes in separate functions so don't know why this should happen. They work fine when used on their own. I'll try something else to see if that's the case though... Cheers.

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Issue with scrolling that I just can't fix

Post by POLYGAMe » Sun Feb 14, 2016 5:14 am

r57shell wrote:write equations, how much should be scroll on top of road.
and you'll see your bug.
reason is because you're calculating from bottom.
Looks like you were right. I combined the two into one function and made it less messy and counted through all 224 lines in sequence and it works. Cheers!

Post Reply