7

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.

1
  • Why do you want to restrict the window size?
    – dnbrv
    Commented Apr 5, 2012 at 4:31

4 Answers 4

6

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 Initialize method:

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
2
  • 1
    Thanks for the information! Ill use it. Also I love your site!
    – Cyral
    Commented Apr 5, 2012 at 23:30
  • also set this.Window.Position = new Point(0, 0); this.Window.IsBorderless = true; if you use MonoGame in fullscreen. In my case without this value, all coordinates make offset not from (0, 0) and rise some artefacts. Commented Aug 6, 2017 at 19:02
2

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!

1
  • 1
    I agree, I've since developed a few games and this is exactly what I do and what seems to be preferred.
    – Cyral
    Commented Oct 23, 2015 at 3:15
1

Make it configurable or user selectable, and allow the user to maximise the window.

There's no need in a modern game to restrict the size of the window the user can play the game in.

1

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.

2
  • Hmm, What I mean is, what size should it be on launch? Ive enabled the maximize button so they can scale it to there screen size and display more tiles and info on screen.
    – Cyral
    Commented Apr 5, 2012 at 0:42
  • 2
    Full screen/maximized at launch. 9 times out of 10, users will play that game exclusively... other than very casual games like Mine Sweeper or Solitaire, games are almost always not multitasked. Players play the game and do nothing else until they are done. If you are aiming for a casual 'off to the side' game such as Solitaire your needs might be different. Commented Apr 5, 2012 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.