How to scroll a 2D background

Well, I've been searching the web and I cannot find a single example of someone scrolling a 2D background using Managed DirectX WITHOUT using the deprecated DirectDraw.

I can already scroll a background using DirectDraw, but I'm trying to be a good boy and stop using the deprecated code. I've been struggling to figure this out for myself, but I'm just not understanding what techniques and objects I would use to scroll a 2D background.

If someone could give me some example code of how to accomplish this with Direct3D or point me in the right direction to a resource that demonstrates the technique to use, that would be great.

So far, everything resource that I  have found online that claims they are scrolling a 2D background using managed DirectX are just doing it the deprecated way with DirectDraw.

Any help at all would be appreciated, I want to kick the deprecated code habit, but it's hard with little examples out there for the 2D game developer.




Answer this question

How to scroll a 2D background

  • marcusaurelius

    If you're looking for more code samples, don't forget to check out the 2D sample in the October SDK!

  • jfy_zhang

    I have some working objects that can do what you are looking for.

    A little while ago I started a 2d scroller for a demonstration program called Phoenix, an have blogged about the work I have done on it (included is the source code for the project)

    The part that should interest you, is that I created a background object that scrolled a star field. All of the code is using Direct3d.

    Links to blog http://www.ircomm.net/blogs/mykre/archive/category/1010.aspx
    Link to the direct post on the background objects http://www.ircomm.net/blogs/mykre/archive/2005/05/24/339.aspx

    Mykre
    www.ircomm.net
    Managed DirectX and Game Programming Resources

  • Alberto Manzanilla

    That is EXACTLY what I was looking for. What's funny is I came across your site earlier in my search but I thought you were drawing a black background and then drawing stars as various sprites on top of it.

    So I didn't think you were moving a background at all, but instead were just moving the random star sprites you sprinkled across it to simulate a ship moving through space. Man, was I way off. That's what I get for just glancing at the code.

    Just to let you know, after looking at your code tonight I was able to get my own 2D side scrolling background to work. Thanks again, you can't imagine what a relief it is to finally understand how to make that work and now actually SEE my background scrolling.

    Nice job, I really appreciate you taking the time to help me out. Guess I can finally start kicking that old deprecated DirectDraw code to the curb.


  • DeTraut

    I'll be sure to check it out David, thanks! I remember you saying before that a 2D sample was going to be included, but then I totally forgot to look at it! Thanks for reminding me.


  • Canuck

    Glad that I could help, But you could also help...

    As you are working to use Direct3d instead of Direct Draw, you might be able to help by documenting some of the things that you are working on so that others may also drop DirectDraw. You are more then welcome to publish your work in the forums on Inner Realm.

    Mykre
    www.ircomm.net
    Managed DirectX and Game Programming Resources.

  • Antonio Yonekura

    I just wanted to let you know Mykre that I have taken your advice and am trying to document my progress on my little side project in 2D development with Managed DirectX (without using DirectDraw). I am attempting to keep my progress chronicled at Storyteller Software, but I'll admit it's a little short on code samples right now. I'm hoping to correct that as time goes on (just overcame one of my hurdles of simplifying the time consuming process of making my VB code look good in HTML), but I just wanted to say thanks again for your help in kick starting my project and I hope that I can repay the favor for others that have questions on 2D development with Managed DirectX.

    Thanks again and I plan on continuing to use you and your site (as well as these forums) as a great resource for me.




  • How to scroll a 2D background