Skip to content

Position_free

hugh greene edited this page Jun 20, 2022 · 1 revision

Description

Checks if there are no instances of a solid object that collide with the given position and returns the result.

Parameters

Parameter Data Type Description
x cs_scalar x coordinate of the position
y cs_scalar y coordinate of the position

Return Values

boolean: Returns whether no instances of a solid object collide with the position.

Example Call

// demonstrates checking if there is an instance of a solid object at the next position before moving
var mx, my;
mx = x + lengthdir_x(speed, direction);
my = y + lengthdir_y(speed, direction);
if (position_free(mx, my)) {
  x = mx;
  y = my;
} else {
  // there is an instance of a solid object at the next position so we can't move
}

NOTOC

Clone this wiki locally