Results 1 to 12 of 12

Thread: [RESOLVED] Screen Resolution

  1. #1

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Resolved [RESOLVED] Screen Resolution

    I'm looking for some advice on how to make my app work with different resolutions as I have posted a demo game on the forum but the game was designed on my laptop which is set to 1280x800 but a few people who have tried the demo are having problems as they are using 1024x768.

    Is this a case of getting the computers resolution when the app starts and alter the size and position of controls?

    Any help is appreciated.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Screen Resolution

    Yes - Games should be able to adjust to the size of the screen. Scale and reposition the items based on the screen size.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Screen Resolution

    Since your game is based on a play-area that is of a defined size, why not just create a form that is the proper size, instead of attempting to make it full screen?

  4. #4

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Screen Resolution

    But what if I want it full screen? For the demo that I have published I can resize the form but the current project I am working on has been designed to be full screen.

    Can anyone advise on how to go about sorting out this problem?

    How can I work out how the graphics need to be resized?

  5. #5
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Screen Resolution

    Are you using DirectX or just regular forms and screen manipulation?

    If you're not using DirectX, My.Computer.Screen.WorkingArea returns a rectangle that gives you the working area of the screen (ie the resolution of the screen, less fixed items like docked toolbars etc).

    In terms of sizing things, again it depends on what method you are using, but if you have all your current code set up to position items based on a set screen size you could simply work out x and y ratios of the actual screen size compared to the base screen size, and factor all positions by the x and y ratios.

  6. #6

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Screen Resolution

    I'm using XNA and the XNA game object rather than a form

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Screen Resolution

    Well so everything you draw must be in relation to the screen and its size. There is nothing more to it.
    Use Me.graphics.GraphicsDevice.ViewPort to retrieve information about the screen.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  8. #8

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Screen Resolution

    But I don't really understand.

    Say I have the frame of my game board which was created based on a resolution of 1280x800 and has the following properties:

    Height: 375
    Width: 250
    X: 200
    Y: 200

    If I detect that the users resolution is 1024x768 then how do i work out the new size and location for this rectangle?

  9. #9
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Screen Resolution

    If you on a 1280x800 surface have a 250x375 frame, then the calculate the proportions like so:
    250 / 1280 = 0.195
    375 / 800 = 0.469

    Now you'd just set the frames width to 0.195 * Me.graphics.GraphicsDevice.ViewPort.Width and the height to 0.469 * Me.graphics.GraphicsDevice.ViewPort.Height.

    The X and Y coordinates would be done in the same way:
    200 / 1280 = 0.156
    200 / 800 = 0.25

    Set the X coordinate to 0.156 * Me.graphics.GraphicsDevice.ViewPort.Width and the Y coordinate to 0.25 * Me.graphics.GraphicsDevice.ViewPort.Width.

    I think thats the best way of going about it, altough I'm relatively fresh with XNA aswell.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  10. #10

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Screen Resolution

    Ok cool I shall give that a go, thanks

  11. #11

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Screen Resolution

    Would I have to create different size images aswell for each resolution setting?

  12. #12

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Screen Resolution

    Have just tried what you said and it works perfect. If the screen setting is 800x600 it does distort the graphics slightly but I don't suppose many people use 800x600 any more.

    Just gotta go through all my graphics and text and alter the size and positions.

    Thanks again for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width