1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

How to zoom out?

Discussion in 'Programming' started by redman, Aug 8, 2016.

  1. redman

    redman Guest

    How do I zoom out (everytime the Player grows in size)? Is there a code to set the "View in room"?
  2. Nux

    Nux Member

    Jul 7, 2016
    you can increase view_wview and view_hview to expand the view on screen! ;o
    (may result in malformed pixels)
    Badger, redman and (deleted member) like this.
  3. redman

    redman Guest

    Thank you. Any way to avoid malformed pixels?
  4. Nux

    Nux Member

    Jul 7, 2016
    kind of.
    if you're zooming out by fractions/decimals, then... no.
    however, you can avoid malformed pixels by using whole numbers
    multiplying by 2 (decimals like x1.5 will cause malformed pixels)
    multiplying by 3
    multiplying by 4
    multiplying by 10

    It's really only a problem if your game is really far zoomed out like risk of rain.
    if you have a zoomed in view - like in super mario, nuclear throne, or undertale - then it's not even noticable and I wouldn't worry!
    Last edited: Jul 18, 2017
    redman likes this.
  5. redman

    redman Guest

  6. L0v3

    L0v3 Guest

    This is part of my camera system. You need to set the global.camera_index somewhere in your code. Just use 0, for default view. You could also just default the script to 0.
    This zooms the camera out over time, might it save you some time. Just use it anytime you wanna zoom stuff out.

    ///camera_zoom(x_scale, y_scale, steps, percentage, inside);
    // Zooms the camera by the given factor over given amount of steps.
    // Make sure global.camera_index have been initilazied by using camera_setup().
    // x_scale          = Scale factor for the x value of camera.
    // y_scale          = Scale factor for the y value of camera.
    // steps            = Number of steps for the zoom effect to complete.
    // percentage       = If scaling is percentage (True) or a size value (False).
    // inside           = Whether the camera will be clamped inside room (True) or allow outside (False).
    // Dependencies: eng_camera_zoom, global.camera_index
    //Creates variables.
    var x_scale = argument0;
    var y_scale = argument1;
    var steps = argument2;
    var percentage = argument3;
    var inside = argument4;
    var index = global.camera_index;
    //Check if scaling is percentage.
    if percentage
        //Calculates value of new scale.
        var x_value = view_wview[index] * x_scale;
        var y_value = view_hview[index] * y_scale;
        //Sets value of the scale.
        var x_value = x_scale;
        var y_value = y_scale;
    //Calculates delta.
    var x_delta = x_value - view_wview[index];
    var y_delta = y_value - view_hview[index];
    //Calculates step value.
    var x_step = x_delta / steps;
    var y_step = y_delta / steps;
    //Create camera object.
    var obj = instance_create(x, y, eng_camera_zoom);
    //Sends over variales.
    with obj
        self.inside = inside;
        self.x_step = x_step;
        self.y_step = y_step;
        self.index = index;
        alarm[0] = steps;    

    This is the eng_camera_zoom object the script creates which handles zooming.

    Alarm 0 Event
    Step Event
    ///Handles Zoom Effect
    //Updates view port.
    view_wview[index] += x_step;
    view_hview[index] += y_step;
    //Centers the camera.
    view_xview[index] -= x_step / 2;
    view_yview[index] -= y_step / 2;
    //Check if inside.
    if inside
        //Clamps values inside room.
        view_xview[index] = clamp(view_xview[index], 0, room_width - view_wview[index]);
        view_yview[index] = clamp(view_yview[index], 0, room_height - view_hview[index]);
    jobjorgos and redman like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice