Well, I have my animated menu.. not completely done, but it’s time to move on for a bit. The first thing I needed to do was figure out how this whole viewport thing worked.. MSDN offers a great help page. The sameple code on the page is a 2d version, and of course, the link to download the source.. but its different code.. 3d.. ah well. I figured it out.

Viewports are actually a lot easier to use than I imagined. In the squiggle, I plan to allow to players to play on the same pc. I know nothing on networking, and dont have much of a way to test it either, so for now, network squiggling is out. For 2 players to race head to head though, I had two options. Draw both players on the same playing field.. which wouldn’t work, or split the screen. So I split it.

Now, with a couple extra lines, I now have my screen split in the middle with a top half and a bottom half, and the ability to render to both individually. The one thing I have to figure out though, is I am passing my spritebatch a matrix that automatically scales my content based on the resolution the user chooses.. well, in a split screen mode, it cant display it all since I have standard wide and half height.. so I have to squish it down.. Which looks ok. not great.. ok.. at least for the water, gravel and general background items.. the player and the obstacles though, ugh.

Right now I have a function added to the screenManager.cs that goes like this:

public Matrix GetResolutionMatrixScale()
	int sx = graphics.PreferredBackBufferWidth;
	int sy = graphics.PreferredBackBufferHeight;
	Matrix matrixScale = Matrix.CreateScale((float)sx / 1024, (float)sy / 768, 1f);
	return matrixScale;

Now, for my spriteBatch.begin call, I can simply do this:


So, if all my content is designed for 1024×768, it scales happily to whatever 4:3 resolution the user sets. Splitting that is ugly, and I dont know if I need a camera here or not. Now what I can do, is change my matrix above from 768 to 1536, which will shrink my background images appropriately to fit in the new viewports, but the player is squeezed as well. Now, I could just go in and change the 1024/2048, but that would mess with my background images.. So I’m going to have to find some kind of compromise here.. I know my background will be tiled and scrolling, but if they get shrunk to a full half and tiled like this, its not going to look right. So there has to be a solution somewhere.. asided from seperate assets for each.

Im thinking I might be able to scale the players & enemies widths, since the height is already scaled from the matrix, so thats one option. But then again, that involved collision detection on a per pixel level with a scaled sprite.. not sure how much hell that is going to be.. ah well. Any ideas, feel free to mail me: squigglyfrogstudios _@_ q dot com.