Scrolling 2D Background XNA Tutorial Question

I posted this in another thread and was given alot of help, and told to make a new thread.
Please see below:

A small FYI and a question from myself as I start to go through this peice by peice.

(code is placed inside of [code] blocks just for easier reading, and incase the forum contains the ability to make it look nice.)

I followed the tutorial and ran the created code with an image that was 800x600 and noticed that the peice was about 1 inch to far from the left. There appears to be a small typo in the tutorial:

[code]
// Set the origin to the center of the texture.
origin = new Vector2( mytextureinfo.Height / 2, mytextureinfo.Width / 2 );
// Set the screen position to the center of the screen.
screenpos = new Vector2( screenwidth / 2, screenheight / 2 );
[/code]

Should really read:
[code]
// Set the origin to the center of the texture.
origin = new Vector2( mytextureinfo.Height / 2, mytextureinfo.Width / 2);
// Set the screen position to the center of the screen.
screenpos = new Vector2(screenheight / 2, screenwidth / 2);
[/code]

I noticed that they changed the order of the math which throws things all out of whack. I think this might need to be fixed in the tutorials for the next release.

My question is this:

After correcting the code for the image, it scrolls down by 100 pixels and then when the image hits the following snipit block:
[code]
// If the entire screen isn't covered, draw a second
// texture above the first by offsetting the screen position
if (screenpos.Y > mytextureinfo.Height/2)
{
Batch.Draw( mytexture, screenpos - offset, null, Color.White, 0, origin, 1, SpriteEffects.None, 0f );
}
[/code]

The image repeats, but it makes the first image disappear... so basically it leaves a blank spot and you can visibly see the background repeat, and that looks kind of ugly.

Any ideas on this one?

Thank you in advance,

-TmK

[2086 byte] By [tmk7] at [2007-12-24]
# 1
Just to clarify the tutorial he is talking about is the scrolling background tutorial found in the XNA help documentation. That's why I recommended he start a new thread so you guys [Michael, Mitch, David you there? ;) ] could help him out a little.

Also, seems he's found a typo, error in that tutorial as well. I haven't checked to see if it's been reported in Connect yet, but if it hasn't, I guess it probably should be.

GeorgeClingerman at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2

Okay this might or might not help

When the screenpos is set to (screenheight / 2, screenwidth / 2) this says it will draw in the middle of the screen. One of the confusing aspects of this is that most regular .Net application draw things by thier top-left corner but this is not the case here.

If you look above that code line you notice the origin

origin = new Vector2(mytextureinfo.Height / 2, mytextureinfo.Width / 2)

This states that it will draw this texture by it middle position so no matter how big or small this texture is it will the middle will draw in the same place. Now I haven't looked at the tutorial I'm just looking at the code you wrote.

Another thing is try creating another spritebatch and drawing the second texture by it.

Later I'll look at the tutorial and reply with probably a better answer so for right now this is all I can give you.

A 13 Year Old Programmer

Seriously

wakawaka54 at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3
George,

I actually used your tutorial, and modified it so that it scrolls top down and repeats the texture that I had twice (it really was a basic texture)

It works really nice for the little thing I am working on, good job on the tutorial by the way

-TmK

tmk7 at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 4
Thanks, I'm glad it helped! I'm sorry no one from Microsoft popped in to help with their tutorial. Sometimes these posts just get a little lost with all the questions they get bombarded with day after day.

Anyway, looks like you're moving forward on your project so I'm glad you got something that works for you. Thanks again for the feedback, also, feel free to email me any suggestions you have on how I could improve the presentation of my tutorials.

I've got a new one that should be going up sometime this week so I've been trying to take all the feedback I've gotten so far and make the modifications people have suggested.

GeorgeClingerman at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...