# very simple question

• 04-12-2002
SuperNewbie
very simple question
Hi,guys

In the game,how could I make the background to keep moving with only one ground bitmap?
Is there any trick for this?

ThanX!!
• 04-12-2002
jdinger
If you mean moving like side-scrolling then you can try this:

Say for instance your game screen is 300 pixels wide and your
background bitmap 300 pixels wide too. Define a variable (int i for
our purposes) to hold the start of your bitmap (at first this would
be 0). When needed (say the user pushes the right arrow key to
make your hero walk), you incriment the bitmap start int. In your
blit routine you would test to see if(i==0). If so, then blit your
bitmap starting a 0. If not, run a blit 2 instances of your bitmap.
The first will have a Source X of whatever i equals, will have a
width of (300-i) and will have a Destination X of 0. The second will
have a Source X of 0, a width of (300-i) and a Destination X of i.

Here's an example (pseudo) of this if the hero walks 10 pixels to
the right:

Code:

```//look, Ma! Code tags! if(i==0) {   blit grass.bmp starting at destinatin 0 with source width of 300 and source starting at 0 } else {   //1st part   blit grass.bmp starting at destination 0 with source width of 290 and source starting at 10   //2nd part   blit grass.bmp starting at destination 290 with source width of 10 and source starting at 0 }```
If this isn't what you're looking for let me know and hopefully I
can explain another method.
• 04-13-2002
SuperNewbie
/////------------------------------------------------------------------------------

If not, run a blit 2 instances of your bitmap.
The first will have a Source X of whatever i equals, will have a
width of (300-i) and will have a Destination X of 0. The second will
have a Source X of 0, a width of (300-i) and a Destination X of i.

////-------------------------------------------------------------------------------

Thank you very much for the help, but about the blit 2, you mean
first have a source X of whatever i equals, and the width of (300-i)
and blit to destination X of 0. The second will have a source of 0, a width of i and destination start of (300-i)

and test
(if i ==300)
i= 0;
blit 1;

am I right? :)
• 04-13-2002
jdinger
Quote:

and test
(if i ==300)
i= 0;
blit 1;

Yes. Sorry I forgot to mention checking for i==300 to reset itself,
but that's right.