collision_line(x1,y1,x2,y2,obj,prec,notme)

From ENIGMA
Jump to navigation Jump to search

Description

Checks the given object for collision with the given line and returns the result.

Parameters

Parameter Data Type Description
x1 cs_scalar x coordinate of the first point of the line
y1 cs_scalar y coordinate of the first point
x2 cs_scalar x coordinate of the second point of the line
y2 cs_scalar y coordinate of the second point
obj integer index of the object whose instances are to be checked for collision, can also be the constant all, or the id of a specific instance
prec boolean whether or not to use precise collision detection
notme boolean whether the object calling the function should not be checked for collision as well

Return Values

inst_t: Returns an instance iterator of the first instance that collides, or the constant noone which is -4.

Example Call

// demonstrates checking if there is a wall between the player instnace and an enemy instance
var inst;
inst = collision_line(obj_player.x, obj_player.y, obj_enemy.x, obj_enemy.y, obj_wall, false, false);
if (inst != noone) {
  // there was a collision with a wall between the player and the enemy
} else {
  // there was no collision
}