GameMaker how does move_wrap work?

S

Shadowblitz16

Guest
how does move_wrap work?
like what would it translate into gml?

I currently have this to wrap at a certain point
Code:
/// @description move_wrap_ext()
/// @param wrap_x_min
/// @param wrap_y_min
/// @param wrap_x_max
/// @param wrap_y_max
/// @param hor
/// @param vert
/// @param margin

var w      = argument[2] - argument[0]; 
var h      = argument[3] - argument[1];
var ox     = argument[0];
var oy     = argument[1];
var hori   = argument[4];
var vert   = argument[5];
var margin = argument[6]

if (hori)
{
    if      (x < ox-margin) x+=w;
    else if (x >  w+margin) x-=w;
}

if (vert)
{
    if      (y < oy-margin) y+=h;
    else if (y >  h+margin) y-=h;
}
 

TheouAegis

Member
You take the x coordinate, check if it's less than the minimum plus the margin, if it is, you set it to the maximum. ELSE if it's greater than the maximum minus the margin, set it to the minimum. Then do the same for y.
 
Top