Jump to content


Photo
- - - - -

Adapt game resolution


  • Please log in to reply
5 replies to this topic

#1 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 518 posts

Posted 21 March 2012 - 08:45 AM

  • Title: Adapt game resolution
  • Description: Change the view size to whatever screen resolution the player is using.
  • GM Version: :GM8:
  • Registered: not sure but I dont think so.
  • File Type: .gmk
  • File Size: 43 KB
  • File Link: Yoyogames link
Summary
I used this technique for my Nyan Cat Screensaver. (this example is actually an early version of that screensaver).
Use this for your game if:
  • Your game runs in full-screen mode
  • if it doesn't matter how far the player can see
Most games have the problem that the game's view size does not synch with the screen resolution of the computer it is played on. So it might look good on your computer, then when you upload it and people start playing it, they will complain that it looks stretched or wierd. Most GM developers solve this by setting the screen scale mode to "keep aspect ratio" or "Fixed scale in 100%". That will however create black borders around your game, which never looks good.

To solve this problem and make it look good, no matter which screen resolution the computer it is played on has, you need a few lines of code and set game settings correctly. Download the .gmk example and read the below steps. These steps are included in the help file of the .gmk.



Step one - Game Settings:
  • In Game Maker, Click "Resources / Change Global Game Settings".
  • Check the box "Start in full-screen mode".
  • Just underneath that, check the circle "Fixed Scale (in %):" and set the value to "100".
  • Click OK.



Step Two - setting up a room correctly:
  • Create a room
  • Set room width and height to something like 3000x3000. The view size will never be larger than the room size, so if you have a room size of 640x480, the view size will never be larger than 640x480 (a border will in that case appear, but in those cases you will most likely want to run the game in a window).
  • Go to the "View" tab in the room.
  • Make sure both "Enable use of views" and "Visible when room starts" is NOT CHECKED! both should be empty.


Step three - The coding:
  • Create a new object, name it something like obj_viewController
  • In any one-time event (like Create,Room/Game start, key press/release, and NOT step or Keyboard), add the script below. You are most likely to use the room
    start or create event, or an event that toggles full-screen mode.
view_wview[0] = display_get_width();
view_hview[0] = display_get_height();
view_wport[0] = display_get_width();
view_hport[0] = display_get_height();
view_enabled = 1;
view_visible[0] = 1;





Now it is all done! Your game view will change according to the player's screen resolution! It will never look wierd or stretched.
Play your game and see for yourself!

Edited by Pandaboy, 26 July 2012 - 01:44 AM.

  • 0

#2 laboomastik

laboomastik

    GMC Member

  • New Member
  • 1 posts
  • Version:Mac

Posted 26 March 2012 - 03:19 PM

Hi Pandaboy and tx for your tips
I just hope u can clarify a bit the step 3, i'm a bit stuck rigth now
Cheers
):
  • 0

#3 Fira

Fira

    God Bless You All

  • GMC Member
  • 1399 posts

Posted 27 March 2012 - 02:13 AM

Why does this require Pro [if requires Pro]? Great example btw [by the way].
  • 0

#4 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 518 posts

Posted 29 March 2012 - 01:55 AM

Hi Pandaboy and tx for your tips
I just hope u can clarify a bit the step 3, i'm a bit stuck rigth now
Cheers
):


What I mean by "a one-time event" is an event that only happens once.
for simplicity, just put the code in the create event of an object and it should work, or, you can just copy the TUTORIAL object from the example file I uploaded. place it in the first room of the game and make sure the room follows step 2.

Why does this require Pro [if requires Pro]? Great example btw [by the way].


wait a minute... I don't think this would require pro. I don't know why I wrote "yes" in that list :P.
If someone uses GM lite, would you please try downloading the .gmk file and see if it works?

Edited by Pandaboy, 29 March 2012 - 01:57 AM.

  • 0

#5 Magicnanners

Magicnanners

    GMC Member

  • New Member
  • 11 posts
  • Version:GM8

Posted 11 July 2012 - 05:50 PM

Thank you so much for this it was extremely helpful :D
  • 0

#6 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 19 July 2012 - 07:50 PM

I've been looking for something like this! ThxPosted Image
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users