I'm making a game with XNA, what I'm wondering is; what should the dimensions in pixels be of the window? It needs to be a size that will work on the majority of computers. I'm not sure if there's some size that most games use.
On a PC or the Xbox 360, there's no single size that is "best", or that all games tend to use. (The Windows 7 Phone has far fewer choices.)
There's no reason to not use the native window resolution by default.
In XNA, you can do this with code like this in the
int width = GraphicsDevice.DisplayMode.Width; int height = GraphicsDevice.DisplayMode.Height; this.graphics.PreferredBackBufferWidth = width; this.graphics.PreferredBackBufferHeight = height; this.graphics.IsFullScreen = true; this.graphics.ApplyChanges();
Of course, it would be meaningful to provide the user with options to change the size they are using, as ChrisF points out. Many people may not ever use it if you've chosen a good default. Still, though, it's one of those things that makes a big difference for the people who want it, and it doesn't take a whole lot of work.
You can also find a good list of common screen resolutions on Wikipedia.
Your biggest challenge in this area will be writing your game in a way that it can handle a wide variety of resolutions and aspect ratios. This is especially true if you want to run the same game/codebase on the PC, the Xbox 360, and the Windows 7 Phone, all of which, XNA supports. From a technical standpoint, here's a few things you can do to help address this problem:
- Build content for the largest window size that you'll support. Drawing a 1920x1080 background on an 800x480 screen has its problems, but not as bad as drawing an 800x480 background on a 1920x1080 screen.
- Along with #1, if you have time, you might want to consider supplying different sets of content to different devices. Or simply loading different sets of content at runtime. This might be especially important for your sprite fonts, which may not scale nearly as well as other things.
- Find an intelligent way to support the two prominent aspect ratios (4:3 and 16:9). For a 3D game, that will almost certainly mean choosing a different field-of-view angle for a perspective projection. A 2D game might require something like letterboxing, but do it in a more creative way than just black bars on the sides.
- Detach your game's internal coordinate system from screen coordinates. Your game will have a behind-the-scenes coordinate system. Do not use the window's coordinates as that behind-the-scenes coordinate system. For example, let's say you're making Asteroids. You will be keeping track of the player's ship's position. It is possible to just say "my ship is at pixel (56, 213) on the screen." But don't do that. Come up with your own internal coordinate system, and when it comes time to draw it, apply some sort of transform to figure out where (and how big) it should be on the screen. Because you're keeping track of things in your behind-the-scenes coordinate system, you can apply different transforms for different resolutions and aspect ratios. And it makes it easy to make a 3D version of your game using the same logic, if you ever choose that route.
Why do so many games default to some random low resolution? If you can write a game, surely you can find some code to detect the screen resolution?
So anyway, a normal game should default to fullscreen, and use the full monitor resolution. Alt-TAB should work to pause the game and switch windows without ill-effect. Alt-Enter or F11 should toggle fullscreen / windowed mode. I guess you should also provide settings to change the resolution, although personally I wouldn't use them if the game does the right thing to begin with. It should remember the settings and use them next time you start the game.
If you get all this stuff right you'll be doing better than the majority of games out there, even many AAA titles!
Use scalable assets when possible, and use the full resolution of the screen. There is no reason to require a user with a large monitor to be stuck with a 1/4 screen window due a limit of 800x600 screen size. I have specifically dropped games, despite promise in their gameplay, if I cannot play them fullscreen and at my native monitor resolution.
A better question might be aspect ratio. This is a harder one, because the majority of screens are now 16:9 or 16:10, but there are still a lot of 4:3 monitors out there. Adjusting the aspect ratio of a game is more difficult than simply scaling the UI, as it requires dealing with anchoring and whitespace. If you cannot make your user interface adjust to multiple aspect ratios, then you should allow the screen to letterbox as needed when the screen ratio does not match your game UI ratio.