Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Backdrop Scrolling Help

Author
Message
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 16th Aug 2010 18:22
So lately I've been working with scrolling backgrounds. I can scroll a background when the space button is pressed with this code:



"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):



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
Terrorist Zero
18
Years of Service
User Offline
Joined: 29th Aug 2006
Location: Teh YouKai
Posted: 17th Aug 2010 02:28
Here's a good reference for 2D scrolling techniques:
http://www.toymaker.info/Games/html/2d_scrolling.html

The code itself uses Direct3D, however the concept is the most important thing on the page.

Generally I would tend to use two backgrounds, moving them both, and once one falls outside the screen bounds, reset that background so it's behind the second (e.g. adding size*2 to its current position).


AMD X2 6400+ (3.2GHz) // K9A2 Platinum 790FX Mobo // 2GB Corsair RAM 1066MHz // Powercolor HD4870 512MB OC'ed
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 17th Aug 2010 16:43
I think I get what your saying, but my problem is that when I try to scroll both backgrounds one stops. What should I do to prevent this stopping?

Learning C++
Proud member of www.codecall.com
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 17th Aug 2010 21:46 Edited at: 17th Aug 2010 21:48
That's a bug somewhere in your code. If you want to scroll both backgrounds, you simply need to change the coordinates of both background sprites.

From the code segment that you posted earlier, it is not possible to figure out the problem (and it looks rather confusing with all those hardcoded numbers, without knowing exactly what your plan was) but I see there only one dbSprite command. If that's one of the background sprites, then where is the other one? If you can't find where the problem is, it would be better the post the whole code.
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 18th Aug 2010 00:40
Would the problem be that I have the second background's Y coordinate equaling the first backgrounds Y coordinate? Like so:



If not then I shall post the whole code. (as a side note: The reason I have "d = b" is because the background scrolls up and down as well, so I want to the second background to appear with the same Y coordinate as the first. Do you know what I'm saying? Is there a better way to do this?)

Thanks!

Learning C++
Proud member of www.codecall.com
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 18th Aug 2010 00:40 Edited at: 18th Aug 2010 00:41
EDIT: Sorry for the double post, didn't realize I posted twice.

Learning C++
Proud member of www.codecall.com
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 18th Aug 2010 15:57
Are you sure you need such a big background? Seems aweful wastefull with video memory.

If your positive about it, research tile based mapping as that sounds like what you need - except your tiles are 2000 x 2000. The mathematics would be the same.

JTK
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 20th Aug 2010 16:10
Well the reason I need such a big background is this: I'm basically making my game surrounded by a bands music. I'm creating each level around one song. I need the backdrop to be long enough to have the whole song play. Would there be a more efficient way of doing this?

And I just thought of something last night... could the reason that my background is being compressed be that I'm using a signed integer to hold the x and y coordinates? It can only hold so high of a number.

Do you know where I could find a tutorial for tile based mapping?

Thanks!

Learning C++
Proud member of www.codecall.com
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 20th Aug 2010 19:33
You mean "Rock-Band" or "Guitar Hero" type scrolling (but 2D)?

In that case, I'd use a different approach:

One image as the background - showing a town, band whatever.
One image as the scrolling image within the "play area" and
several images representing the Buttons and Slides etc.

The attached project shows how I would go about it. I'll leave it for you to figure out the remaining details, but this should be a good start! Maybe check out "Top-Down Scrollers" to find more details, that may help you out too...

Good Luck,


JTK

Attachments

Login to view attachments
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 23rd Aug 2010 14:03
I think my post mislead you. Its actually a side scrolling game where you get a sprite from one part to the other, while music is playing in the background. Game-play doesn't actually affect music. Do you know what I mean?

Learning C++
Proud member of www.codecall.com
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 23rd Aug 2010 16:05
Yeah. Instead of SetVelocityY() play with the SetVelocityX() instead.

You'll have to change the buttons and slides in the demo above but it will change the scrolling left to right.

SetVelocityY scrolls up/down.
SetVelocityX scrolls left/right.

They are not exclusive of each other; you can scroll up/down and left/right at the same time.

The int value passed in is the number of pixels to scroll by...

JTK
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 24th Aug 2010 20:26
To me this seems like your using an overly complicated system to scroll the background. Not sure if there is a reason for some of that code but, maybe this might help you out a bit.



Depending on how many background segments you intend to use later on you could make this more efficent by only having a max of 2 segments loaded in at a time and as the first leaves the screen loading in the next one and clearing out the old one but I'll leave that to you. Hope this helps you out some and good luck.

Login to post a reply

Server time is: 2024-11-19 18:36:43
Your offset time is: 2024-11-19 18:36:43