How to Scale the View in GameMaker: Studio - dummies

How to Scale the View in GameMaker: Studio

By Michael Rohde

GameMaker: Studio allows you to scale your game to fit the size of the window, no matter the dimensions of the window. You can also scale the View. When working with Views, you tell GameMaker to show only a certain portion of the Room at a time, which is how this tutorial is set up.

However, if the player’s window is big enough to show more of the View than what you set in the Room, you can update the Script from the last procedure.

  1. With the tutorial open, in the Resource tree, from the Scripts folder, double-click scr_Resize.

    The Script code window appears.

  2. In the code window, update the code to reflect the following (the code in bold indicates the differences):

    cur_width = max(1, window_get_width());
    cur_height = max(1, window_get_height());
    var ratio = cur_width / cur_height;
    if cur_width < cur_height
        view_wview[0] = median(min_height, cur_height, room_height);
        view_hview[0] = view_hview[0] * ratio;
        view_wview[0] = median(min_width, cur_width, room_height);
        view_hview[0] = view_wview[0] / ratio;
    view_wport[0] = cur_width;
    view_hport[0] = cur_height;
    surface_resize(application_surface, view_wview[0], view_hview[0]);
  3. Click the green check mark to save and close the Script code window.

GameMaker displays as much of the Room as it can within the window while maintaining the appropriate aspect ratio. You can press the spacebar to change Rooms to see how the window and view adapts to different Room sizes.

You may have noticed in the Resource tree that there are two Rooms set up for this tutorial, room0 and room1. When you press the spacebar and switch to room1, you should see much more of the View than you did before.