Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to I make my background scroll. I am developing a game using c# and directX.

Posted on 2005-03-01
6
Medium Priority
?
682 Views
Last Modified: 2013-12-08
I have a game in c# and directX and want to put in a scrolling background. This is a 2D game. All help greatly appreciated.
0
Comment
Question by:pmaguire9
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
davebytes earned 500 total points
ID: 13434341
There are many approaches to scrolling a background, it depends on what the PRECISE effect is you want to obtain, and how large a 'virtual scrolling' section you intend.

For instance, if you have a fixed/wrapping background, larger than one screen width, you can 'simply' offset the coordinates into a large texture, shifting them, and when both side have 'wrapped' off the end you 'jump' them back based off 0,0.

If you want a very dynamic background, you can build it using individual 'tile' graphics.  Each frame, you can completely re-image the background at whatever the current offset is -- with DirectX (Direct3D), all the textures/tiles can be in hardware, makes it really fast to render any tiled layout.

-d
0
 
LVL 1

Assisted Solution

by:lplayer
lplayer earned 500 total points
ID: 13467231
Rather than explain lots of detail here I would suggest you look at:

http://www.gpwiki.org/index.php/Framing_Buffer_Tile_Scrolling_Algorithm

The example relates to VB but the site also containd C++ code too.

0
 
LVL 17

Expert Comment

by:davebytes
ID: 13474055
right.  that only deals with one particular case of tiling, and a somewhat fixed one at that.  what the game IS, how smoothly it wants to scroll, how fixed/dynamic is the background, etc., all play into the answer.

But otherwise, that's a decent link.  However, there's a ton more over at gamedev.net, dealing with a variety of different background methods.  Search on 'scrolling' and you'll see all the links.

-d
0
 
LVL 17

Expert Comment

by:davebytes
ID: 14148815
if you need more help, please ask.  otherwise, this question should be closed or accepted.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question