So lately I've been working with scrolling backgrounds. I can scroll a background when the space button is pressed with this code:
if (dbSpaceKey())
{
backgroundXaxis--;
}
"backgroundXaxis" being the variable to store the x coordinate of the backdrop and I use "--" to subtract from the x cood. That way it scrolls towards the left. Here is my problem:
The original backdrop I wanted to use was to long, so the Dark GDK compressed it to fit the max width of a backdrop. I couldn't sacrifice the length of the backdrop so I had to think Up a way to scroll different sections of the backdrop. (I hope I'm being clear) So I split my backdrop into 2000 pixel increments, ok? Now I want to have the first increment scrolling, which I got. Now when the first increment reaches a certain point, I want the second increment to be loaded in, and scroll. Here is my code(for the scrolling):
int g = -1370;//backdrop
int h = -100; //backdrop
int i = 630; //backdrop
int j = h; //backdrop
int mark = 204; //mark variable
int mark2 = 202; //mark variable
//variables
//Start Scroll
if (dbSpaceKey())
{
mark--; //makes background scroll when space button pressed
}
if (mark == 202)
{
mark++; //makes background scroll when space button pressed
}
if (dbSpriteCollision(10,11))
{
g--; //makes background scroll when space button pressed
}
//Start Scroll
//Level #1
if (g == -1370)
{
dbSprite(12, i, j, 12);
mark2--;
}
if (mark2 == 200)
{
mark2++;
}
if (dbSpriteCollision(16, 17))
{
i--;
}
//Level #1
My issue is that when the first segment is scrolling, the second one sits still. Is there anyway to have 2 backgrounds scroll at the same time?
Is there a better way to scroll 2D backgrounds? What am I missing!?!
Thank you so much, for anyone willing to help he out here,
TeenChristian
Learning C++
Proud member of www.codecall.com