Checks to see whether a given point falls within the defined polygon area.

  • Define a polygonal area. It's just an array of coordinates, like:

    array[0] = 10; // vertex 1 x
    array[1] = 20; // vertex 1 y
    array[3] = 50; // vertex 2 x
    array[4] = 30; // vertex 2 y

    you can use script poly_create for it, like:

    poly = poly_create(10,20,50,30,80,70);

    or use GMS2 syntax:

    poly = [10,20,50,30,80,70];

or use poly_create_from_path(path)

  • When using this function, it's will work out whether the given point falls within it's bounds or not. If the point falls within the defined polygon the function will return true otherwise the function will return false.

  • It's uses ray casting algorithm.

  • Functions:

    • point_in_poly(point_x, point_y, poly)
    • poly_draw(poly)
    • poly_shift(poly)
    • poly_create(value1, value2, ...)
    • poly_create_from_path(path, [counter])
  • I use Tiled map editor to create polygons (see screenshot)

End User Licence Agreement (EULA).

Changes in 1.2.0

Some refactoring made: JSDoc style comments; Removed some functions, like array_create_from_string (because GMS already has no limits for argument count); Functions was renamed (sorry if this breaks your old code). New names: poly_draw(), poly_shift(), poly_create(), poly_create_from_path().

Version 1.2.0. Published April 24, 2017

Age Rating: 4+

Average Rating

Your review

You can only review assets you've bought.


Cyril K 30 October 2014


No comment: it's perfect and very easy to use

This review was left for a previous version of this asset.


Anonymous 22 August 2014

It just works! :)

This review was left for a previous version of this asset.

What is the issue?

Back to Top