How to zoom out?

R

redman

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

Nux

GameMaker Staff
GameMaker Dev.
Any way to avoid malformed pixels?
kind of.
if you're zooming out by fractions/decimals, then... no.
however, you can avoid malformed pixels by using whole numbers
e.g.
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:
R

redman

Guest
kind of.
if you're zooming out by fractions/decimals, then... no.
however, you can avoid malformed pixels by using whole numbers
e.g.
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! ;w;
Thanks!
 
L

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.

Code:
///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;
}
else
{
    //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
Code:
///Suicide
instance_destroy();
Step Event
Code:
///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]);
}
 
Top