Question

Im starting with XNA and i need an advice about the following.

I have a .jpg file with my space ship game background with the following size:

   width:  5000px 

   height: 4800px

When i try to load the texture i get the following error:

Texture width or height is larger than the device supports

What is the most used technique to move the background at the same time that your ship is moving?

Thanks a lot.

Kind Regards.

Josema.

Was it helpful?

Solution

One way would be to separate your image into smaller tiles and draw the visible ones.

However this technique suffers from a problem when bilinear sampling is used, because the colors bleeds from the one side of the texture to the other. You can probably compensate by disabling texture WRAP sampling or by grabbing a single of pixels from the tiles next to.

For example if you want 256x256 textures, you would only display 255x255 tiles, because one line (right and bottom) is a copy from the tiles next to it.

Hope it makes sense, otherwise I'll have to paint a picture :-)

OTHER TIPS

The texture limit is determined by graphics card, I believe. You want to break the texture down to smaller images.

Try something like this. He's tiling a simple 40x40, but you might use it a a guideline on how to tile yours. http://forums.xna.com/forums/p/19835/103704.aspx

To move the background at the same time that your ship is moving you can implement a camera.

The following links might help-

http://adambruenderman.wordpress.com/2011/04/05/create-a-2d-camera-in-xna-gs-4-0/ http://www.dreamincode.net/forums/topic/237979-2d-camera-in-xna/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top