Grids for Game Maker  1.2
A Grids Library for Game Maker
 All Namespaces Functions
grids Namespace Reference

Functions

def gl_get_biggest_pointset
 Returns the biggest pointset from a list of pointsets. More...
 
def gl_get_connected_line
 Gets the line of connected cells through the given point in the given direction. More...
 
def gl_get_connected_lines
 Returns a list of lines conected to a point, where each line is a list of points. More...
 
def gl_grid_astar
 Returns the shortest path between the start and goal nodes in a grid. More...
 
def gl_grid_connected
 Returns true if the points are "connected". More...
 
def gl_grid_connected_set
 Find the set of points connected to the given point in the grid. More...
 
def gl_find_node_with_lowest_score_index
 Private. More...
 
def gl_reconstruct_path
 Private. More...
 
def gl_reconstruct_path_impl
 Private. More...
 
def gl_pointset_create
 Creates a new point set. More...
 
def extra_documentation
 
def gl_instance_create
 Creates an instance of anobject at a given point. More...
 
def gl_instance_get_position
 Returns the position of an instance as a vector. More...
 
def gl_instance_set_position
 Sets the position of an instance to the ggiven vector coordinates. More...
 
def gl_list_add_range
 Adds all the items of one list to another. More...
 
def gl_list_delete_point
 Deletes the first occurance a point (vector) from a list of points. More...
 
def gl_list_exists_point
 Returns true if the given point is an item in the list. More...
 
def gl_list_random_item
 Returns a random item from a list. More...
 
def gl_list_sample_random
 Returns a random sample from the given list. More...
 
def gl_mouse_get_position
 Returns the current mouse position as a vector. More...
 
def gl_random_int
 Returns a random integer between 0 (inclusive) and the given upper limit (exclusive). More...
 
def gl_room_get_extent
 Gets the extent of the current room as a rectangle. More...
 
def gl_sprite_get_size
 Returns the sprite of a sprite as a vector. More...
 
def gl_diamond_distance
 Calculates the node-to-node (taxicab) distance between two diamond points (i.e. More...
 
def gl_diamond_grid_create
 Creates a new diamond grid in a specified shape and size. More...
 
def gl_diamond_grid2world
 Converts a grid point to world point using the given map. More...
 
def gl_diamond_magnitude
 Gives the taxicab-magnitude of the given point, which is how many edges you would have to cross from the origin to the point (if you do not move diagonally). More...
 
def gl_diamond_map_create
 Creates a new map that ccan be used with a diamond grid. More...
 
def gl_diamond_world2grid
 Converts a world point to a diamond grid point. More...
 
def gl_diamond_shape_create_parallelogram
 Creates a new parallelogram (shape) in diamond coordinates. More...
 
def gl_diamond_shape_create_rectangle
 Creates a new rectangle (shape) in diamond coordinates. More...
 
def gl_diamond_shape_create_circle
 Creates a new circle in diamond coordinates. More...
 
def gl_flathex_distance
 Calculates the node-to-node distance between two flat hex points (i.e. More...
 
def gl_flathex_grid_create
 Creates a new flat hex grid in a specified shape and size. More...
 
def gl_flathex_grid2world
 Converts a grid point to world point using the given map. More...
 
def gl_flathex_magnitude
 Gives the hex-magnitude of the given point, which is how many edges you would have to cross from the origin to the point. More...
 
def gl_flathex_map_create
 Creates a new map that can be used for conversions between world points and flat hex grid points. More...
 
def gl_flathex_world2grid
 Converts a world point to a flat hex grid point. More...
 
def gl_flathex_shape_create_fatrectangle
 Creates a new fat rectangle (shape) in flat hex coordinates. More...
 
def gl_flathex_shape_create_hexagon
 Creates a new hexagon(shape) in flat hex coordinates. More...
 
def gl_flathex_shape_create_parallelogram
 Creates a new parallelogram (shape) in flat hex coordinates. More...
 
def gl_flathex_shape_create_thinrectangle
 Creates a new thin rectangle (shape) in flat hex coordinates. More...
 
def gl_get_color
 The parallelogram between (ux, 0) and (vx, vy) defines a grid coloring. More...
 
def gl_grid_clone_structure
 This function returns a grid that is the same shape as the given grid, but without the same data. More...
 
def gl_grid_connection_index
 Returns the connection_index of the cell in the grid at the given point. More...
 
def gl_grid_contains
 Returns true if the grid contains the given point. More...
 
def gl_grid_destroy
 Destroys the given grid. More...
 
def gl_grid_fill
 Sets each cell in the grid to the given value. More...
 
def gl_grid_get
 Returns the value in a grid at a given point. More...
 
def gl_grid_get_iter
 Gets a new iterator for this grid. More...
 
def gl_grid_get_neighbors
 Get the neighbors in the grid for the given point. More...
 
def gl_grid_get_points
 Get all the points in this grid. More...
 
def gl_grid_get_values
 Gets all the cells in this grid, that is, the contents of the grid at each point. More...
 
def gl_grid_neighbors_connected
 Tests whether two points are connected, that is, have the same connection index. More...
 
def gl_grid_random_point
 Returns a random point from a grid. More...
 
def gl_grid_set
 Sets the grid contents at the given point. More...
 
def gl_grid_where_color_equals
 Returns all points in a grid whose color (given the coloring parallelogram) matches the given color. More...
 
def gl_init
 Initializes constants necessary to use Grids. More...
 
def gl_iter_destroy
 Destroys the given iterator. More...
 
def gl_iter_hasnext
 Returns true if the iterator has a valid next value. More...
 
def gl_iter_next
 Returns the next item the iterator points to, and advances the iterator. More...
 
def gl_map_align_grid_in_rect
 Transforma a map so that the grid is aligned in the rectangle given. More...
 
def gl_map_calc_grid_extent
 Calculates the grids placement and size in world space. More...
 
def gl_map_center_grid_in_rect
 This is a convenience method for adjusting a map so that it will center a grid in a rectangle. More...
 
def gl_map_closest
 Returns the world point of the grid point closest to the given world point. More...
 
def gl_map_destroy
 Destroys the given map. More...
 
def gl_map_distance
 Gives the world distance between two grid points. More...
 
def gl_map_flip_x
 Flips a map's world X-coordinate. More...
 
def gl_map_flip_y
 Flips a map's world Y-coordinate. More...
 
def gl_map_get_cell_dimensions
 Gets the cell dimensions of the given map. More...
 
def gl_map_grid2rawworld
 Does the calculation for converting grid coordinates to world coordinates. More...
 
def gl_map_grid2world
 Converts a grid point to a world point using the given map. More...
 
def gl_map_magnitude
 Gives the world magnitude of a grid vector. More...
 
def gl_map_rawdistance
 Calculates the "raw" world distance between two grid points. More...
 
def gl_map_scale
 Scales the map. More...
 
def gl_map_snap
 Returns the world point of the grid point of the given world_point. More...
 
def gl_map_translate
 Translates a map. More...
 
def gl_map_world2grid
 Converts a world point to a grid point using the given map. More...
 
def gl_pointyhex_distance
 Calculates the node-to-node distance between two pointy hex points (i.e. More...
 
def gl_pointyhex_grid_create
 Creates a new pointy hex grid in a specified shape and size. More...
 
def gl_pointyhex_grid2world
 Converts a grid point to world point using the given map. More...
 
def gl_pointyhex_magnitude
 Gives the hex-magnitude of the given point, which is how many edges you would have to cross from the origin to the point. More...
 
def gl_pointyhex_map_create
 Creates a new map that can be used with a pointy hex grid. More...
 
def gl_pointyhex_world2grid
 Converts a world point to a pointy hex grid point. More...
 
def gl_pointyhex_shape_create_fatrectangle
 Creates a new fat rectangle (shape) in pointy hex coordinates. More...
 
def gl_pointyhex_shape_create_hexagon
 Creates a new hexagon (shape) in pointy hex coordinates. More...
 
def gl_pointyhex_shape_create_parallelogram
 Creates a new parallelogram (shape) in pointy hex coordinates. More...
 
def gl_pointyhex_shape_create_thinrectangle
 Creates a new thin rectangle (shape) in pointy hex coordinates. More...
 
def gl_iter_create
 Private. More...
 
def gl_iter_move
 Private. More...
 
def gl_rect_distance
 Calculates the node-to-node (taxicab) distance between two rect points (i.e. More...
 
def gl_rect_grid_create
 Creates a new rect grid in a specified shape and size. More...
 
def gl_rect_grid2world
 Converts a grid point to world point using the given map. More...
 
def gl_rect_magnitude
 Gives the taxicab-magnitude of the given point, which is how many edges you would have to cross from the origin to the point (if you do not move diagonally). More...
 
def gl_rect_map_create
 Creates a new map that can be used with a rect grid. More...
 
def gl_rect_world2grid
 Converts a world point to a rect grid point. More...
 
def gl_rect_shape_create_rectangle
 Creates a new rectangle in rect coordinates. More...
 
def gl_rect_shape_create_parallelogram
 Creates a new parallelogram (shape) in rect coordinates. More...
 
def gl_rect_shape_create_circle
 Creates a new circle in rect coordinates. More...
 
def gl_halfplane_clone
 Clones the given halfplane. More...
 
def gl_halfplane_contains
 Returns whether a point is contained in the given halfplane. More...
 
def gl_halfplane_create
 Creates a new halfplane from the given point and pseudo-normal. More...
 
def gl_halfplane_destroy
 Destroys the given halfplane. More...
 
def gl_matrix3_create
 Creates a new matrix from the 9 given components. More...
 
def gl_matrix3_create_flip_x
 Creates a new matrix that will flip the x coordinate of a vector if that vector is multiplied with the matrix. More...
 
def gl_matrix3_create_flip_y
 Creates a new matrix that will flip the y coordinate of a vector if that vector is multiplied with the matrix. More...
 
def gl_matrix3_create_scale
 Creates a new matrix that denotes a scale transform. More...
 
def gl_matrix3_create_translation
 Creates a vector that represents a translation by the given amount. More...
 
def gl_matrix3_identity
 Returns the identity matrix. More...
 
def gl_matrix3_inverse
 Returns the inverse matrix of the given matrix (provided it has one). More...
 
def gl_matrix3_mul
 Multiplies two matrices together and returns the result as a new matrix. More...
 
def gl_polygon_clone
 Recursively clones this polygon. More...
 
def gl_polygon_contains
 A "polygon" is a list of halfplanes. More...
 
def gl_polygon_destroy
 Destroys the given polygon. More...
 
def gl_rect_create
 Creates a new rectangle. More...
 
def gl_rect_destroy
 Destroys the given rect. More...
 
def gl_rect_get_dimensions
 Returns the dimensions of a rectangle as a vector. More...
 
def gl_rect_get_endpoint
 This function returns the corner of the rectangle opposite to the corner used to construct the rectangle. More...
 
def gl_rect_get_point
 Gets the corner of the rectangle used to construct the rectangle. More...
 
def gl_shape_clone
 Recursively clones a shape. More...
 
def gl_shape_contains
 Returns true if the given shape contains the given point. More...
 
def gl_shape_destroy
 Destroys the given shape. More...
 
def gl_shape_union
 Constructs a new shape that represents the union of the two shapes given. More...
 
def gl_vector_add
 Adds two vectors together and returns the sum as a new vector. More...
 
def gl_vector_create
 Creates a new vector from the given coordinates. More...
 
def gl_vector_distance
 Calculates the Euclidean distance between two vectors, and returns the result. More...
 
def gl_vector_dot
 Returns the dot product of two vectors. More...
 
def gl_vector_equals
 Returns whether two vectors are equal, that is, if corresponding components are equal. More...
 
def gl_vector_magnitude
 Returns the Euclidean magnitude of this vector. More...
 
def gl_vector_mul
 Multiplies a vector with a real number and returns the result. More...
 
def gl_vector_negate
 Negates each component of this vector, and returns it as a new vector. More...
 
def gl_vector_sub
 Subtracts one vector from another, and returns the result as a new vector. More...
 
def gl_vector_transform
 Multiplies a vector with a matrix, and returns the result as a new vector. More...
 
def gl_vector2str
 Returns a string presentation of the given vector. More...
 
def gl_shape_create_polygon
 Creates a new shape from a list of vertices of a convex polygon. More...
 
def gl_vector_perp
 Returns the new vector (-y, x), which in rect coordinates is perpendicular to the give vector. More...
 

Function Documentation

def grids.extra_documentation ( )
def grids.gl_diamond_distance (   p1,
  p2 
)

Calculates the node-to-node (taxicab) distance between two diamond points (i.e.

how many edges you have to cross moving from one node to the other).

Parameters
p1
p2
Returns
An integer denoting the distance between the two nodes.
Since
1.2
def grids.gl_diamond_grid2world (   map,
  point 
)

Converts a grid point to world point using the given map.

Parameters
mapThe map to use for the conversion
pointThe point to convert
Returns
A new vector.
Since
1.2
def grids.gl_diamond_grid_create (   shape_label,
  size1,
  size2 
)

Creates a new diamond grid in a specified shape and size.

Note
You are responsible for destroying the variable using the function gl_grid_destroy
Parameters
shape_labelA string that represents the shape of the grid. The posibilities are "parallelogram", "rectangle".
size1For most shapes, this denotes the width.
size2For most figures, this denotes the height.
Returns
A new grid.
Since
1.2
def grids.gl_diamond_magnitude (   p)

Gives the taxicab-magnitude of the given point, which is how many edges you would have to cross from the origin to the point (if you do not move diagonally).

Parameters
pointThe point whose magnitude to compute.
Returns
An integer.
Since
1.2
def grids.gl_diamond_map_create (   cell_dimensions)

Creates a new map that ccan be used with a diamond grid.

Note
You are responsible for destroying the variable using the function gl_map_destroy
Parameters
cell_dimensionsThe dimensions (as a vector).
Returns
A new map.
Since
1.2
def grids.gl_diamond_shape_create_circle (   radius)

Creates a new circle in diamond coordinates.

(The circle has the shape of a diamond).

Parameters
radiusThe radius of the circle.
Returns
A new shape.
Since
1.2
def grids.gl_diamond_shape_create_parallelogram (   width,
  height 
)

Creates a new parallelogram (shape) in diamond coordinates.

Parameters
widthThe width of the parallelogram in grid coordinates
heightThe height of the parallelogram in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_diamond_shape_create_rectangle (   width,
  height 
)

Creates a new rectangle (shape) in diamond coordinates.

Parameters
widthThe width of the parallelogram in grid coordinates
heightThe height of the parallelogram in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_diamond_world2grid (   map,
  v_raw 
)

Converts a world point to a diamond grid point.

Parameters
mapThe map to use for the conversion.
v_rawThe world point.
Since
1.2
def grids.gl_find_node_with_lowest_score_index (   list,
  score_map 
)

Private.

Since
1.0
def grids.gl_flathex_distance (   p1,
  p2 
)

Calculates the node-to-node distance between two flat hex points (i.e.

how many edges you have to cross moving from one node to the other).

Parameters
p1
p2
Returns
An integer denoting the distance between the two nodes.
Since
1.0
def grids.gl_flathex_grid2world (   map,
  point 
)

Converts a grid point to world point using the given map.

Parameters
mapThe map to use for the conversion
pointThe point to convert
Returns
A new vector.
Since
1.0
def grids.gl_flathex_grid_create (   shape_label,
  size1,
  size2 
)

Creates a new flat hex grid in a specified shape and size.

Note
You are responsible for destroying the variable using the function gl_grid_destroy
Parameters
shape_labelA string that represents the shape of the grid. The posibilities are "hexagon", "fatrectangle", "thinrectangle", and "parallelogram"
size1For most shapes, this denotes the width. For the hexagon, it denotes the side length.
size2For most figures, this denotes the height. For the hexagon, it is ignored.
Returns
A new grid.
Since
1.0
def grids.gl_flathex_magnitude (   p)

Gives the hex-magnitude of the given point, which is how many edges you would have to cross from the origin to the point.

Parameters
pointThe point whose magnitude to compute.
Returns
An integer.
Since
1.0
def grids.gl_flathex_map_create (   cell_dimensions)

Creates a new map that can be used for conversions between world points and flat hex grid points.

Note
You are responsible for destroying the variable using the function gl_map_destroy
Parameters
cell_dimensionsThe size of the cell as a vector.
Returns
A new map.
Since
1.0
def grids.gl_flathex_shape_create_fatrectangle (   width,
  height 
)

Creates a new fat rectangle (shape) in flat hex coordinates.

Parameters
widthThe width of the rectangle in grid coordinates
heightThe height of the rectangle in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_flathex_shape_create_hexagon (   side)

Creates a new hexagon(shape) in flat hex coordinates.

Parameters
sideThe length of the bexagon side grid coordinates
Returns
A new shape.
Since
1.0
def grids.gl_flathex_shape_create_parallelogram (   width,
  height 
)

Creates a new parallelogram (shape) in flat hex coordinates.

Parameters
widthThe width of the parallelogram in grid coordinates
heightThe height of the parallelogram in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_flathex_shape_create_thinrectangle (   width,
  height 
)

Creates a new thin rectangle (shape) in flat hex coordinates.

Parameters
widthThe width of the rectangle in grid coordinates
heightThe height of the rectangle in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_flathex_world2grid (   map,
  v_raw 
)

Converts a world point to a flat hex grid point.

Parameters
mapThe map to use for the conversion.
v_rawThe world point.
Since
1.0
def grids.gl_get_biggest_pointset (   pointsets)

Returns the biggest pointset from a list of pointsets.

Parameters
listA list of list of points.
Returns
The biggest pointset (as a list of points) from the list above.
Since
1.1
def grids.gl_get_color (   point,
  ux,
  vx,
  vy 
)

The parallelogram between (ux, 0) and (vx, vy) defines a grid coloring.

This function returns the color for the given point for the grid-coloring defined by the parallelogram between (ux, 0) and (vx, vy).

See also
http://gamelogic.co.za/2013/12/18/what-are-grid-colorings/
Parameters
pointThe point for which to calculate a color
uxThe x-coordinate of one side of the parallelogram
vxThe x-coordinate of other side of the parallelogram
vyThe y-coordinate of other side of the parallelogram
Returns
an integer index.
Since
1.0
def grids.gl_get_connected_line (   grid,
  point,
  dir 
)

Gets the line of connected cells through the given point in the given direction.

Returns
A line as a list of points.
Since
1.1
def grids.gl_get_connected_lines (   grid,
  grid_point 
)

Returns a list of lines conected to a point, where each line is a list of points.

Parameters
gridThe grid in which to check.
grid_pointThe point to check for.
Returns
A list of lines (each line is a list of grid points). Each line will have at least two points.
Since
1.1
def grids.gl_grid_astar (   grid,
  map,
  start,
  goal 
)

Returns the shortest path between the start and goal nodes in a grid.

This function can only be called when the grid contains GM instances as cells. The cells in the grid must contain a boolean value accessible to indicate whether the cell is accesible or not.

Note
You are responsible for destroying the variable using the function ds_list_destroy
Parameters
grid
map
start(vector)
goal(vector)
Returns
noone if no path has been found; otherwise a list of grid points (vectors) of the path if one has been found
Since
1.0
def grids.gl_grid_clone_structure (   grid)

This function returns a grid that is the same shape as the given grid, but without the same data.

Note
You are responsible for destroying the variable using the function gl_grid_destroy
Parameters
gridThe grid to clone.
Returns
A grid in the same shape as the given grid.
Since
1.0
def grids.gl_grid_connected (   grid,
  point1,
  point2 
)

Returns true if the points are "connected".

A point p1 is connected to another point p2 if either p1 and p2 are neighbors, and the cells at those points have the same connection_index, or if p1 has a neighbor that is connected.

This function can only be called if the grid contains GM instances, and they have the variable connection_index defined.

Parameters
grid
point1
point2
Since
1.0
def grids.gl_grid_connected_set (   grid,
  point 
)

Find the set of points connected to the given point in the grid.

Since
1.0
def grids.gl_grid_connection_index ( )

Returns the connection_index of the cell in the grid at the given point.

You can only call this function on a grid if the contents are GM objects, with variable connection_index.

In connection algorithms, neighbors are connected if their connection indices are equal.

Parameters
grid
point
Returns
The connection index
Since
1.0
def grids.gl_grid_contains (   grid,
  point 
)

Returns true if the grid contains the given point.

Parameters
gridThe grid to use for the check.
pointThe point to check.
Returns
true if the point is in the grid, false otherwise.
Since
1.0
def grids.gl_grid_destroy (   grid)

Destroys the given grid.

Parameters
gridThe grid to destroy.
Since
1.0
def grids.gl_grid_fill (   grid,
  value 
)

Sets each cell in the grid to the given value.

This is a simple way to initialize grids, epsepcially if they don't contain GM objects.

Parameters
grid
value
Since
1.0
def grids.gl_grid_get (   grid,
  grid_point 
)

Returns the value in a grid at a given point.

Parameters
grid
grid_point
Returns
the cell in the grid at the given point.
Since
1.0
def grids.gl_grid_get_iter ( )

Gets a new iterator for this grid.

The typical way to use this is in a while loop to iterate over all points in a grid.

1 var iter = gl_grid_iter_create(grid);
2 
3 while(gl_iter_hasnext(iter))
4 {
5  var point = gl_iter_next(grid);
6 
7  ...
8 }
Parameters
grid.
Since
1.0
def grids.gl_grid_get_neighbors ( )

Get the neighbors in the grid for the given point.

Parameters
grid
point
Returns
The neighbors as a list of grid points (vectors).
Since
1.0
def grids.gl_grid_get_points (   grid)

Get all the points in this grid.

Parameters
grid
Returns
A list of grid points (vectors) inside the grid.
Since
1.0
def grids.gl_grid_get_values (   grid)

Gets all the cells in this grid, that is, the contents of the grid at each point.

Parameters
grid
Returns
A list of values.
Since
1.0
def grids.gl_grid_neighbors_connected (   grid,
  point1,
  point2 
)

Tests whether two points are connected, that is, have the same connection index.

It is assumed the two points are neighbors.

Parameters
grid
point1
point2
Returns
true if the two points are connected, false otherwise.
Since
1.0
def grids.gl_grid_random_point (   grid)

Returns a random point from a grid.

Parameters
gridThe grid from which to return a random point.
Returns
A point (vector) randomly selected from all points in the grid.
Since
1.1
def grids.gl_grid_set (   grid,
  grid_point,
  value 
)

Sets the grid contents at the given point.

Parameters
grid
grid_point
value
Since
1.0
def grids.gl_grid_where_color_equals (   grid,
  ux,
  vx,
  vy,
  color 
)

Returns all points in a grid whose color (given the coloring parallelogram) matches the given color.

See also
gl_get_color.
Parameters
gridThe grid from which to select points
uxThe x-coordinate of one side of the parallelogram
vxThe x-coordinate of other side of the parallelogram
vyThe y-coordinate of other side of the parallelogram
colorThe color index to match.
Returns
A list of points that have the given color index using the specified coloring.
Since
1.1
def grids.gl_halfplane_clone (   halfplane)

Clones the given halfplane.

Note
You are responsible for destroying the variable using the function gl_halfplane_destroy
Parameters
halfplane
Returns
A new halfplane.
Since
1.0
def grids.gl_halfplane_contains (   halfplane,
  point 
)

Returns whether a point is contained in the given halfplane.

Parameters
halfplane
point
Since
1.0
def grids.gl_halfplane_create (   point,
  pseudo_normal 
)

Creates a new halfplane from the given point and pseudo-normal.

Note
You are responsible for destroying the variable using the function gl_halfplane_destroy
Parameters
pointA point on the border of the halfplane.
pseudo_normalIf the half-plane border is (parallel to) the line a*x + b*y = 0, then the pseudo-normal is the vector (a, b) or (-a, -b). The two possibilites correspond to the two sides of the line.
Returns
the halfplane
Since
1.0
def grids.gl_halfplane_destroy (   halfplane)

Destroys the given halfplane.

Parameters
halfplaneThe halfplaneto destroy.
def grids.gl_init ( )

Initializes constants necessary to use Grids.

Since
1.0
def grids.gl_instance_create (   position,
  obj 
)

Creates an instance of anobject at a given point.

Parameters
position(A vector in world-space).
objthe object to instantiate.
Since
1.0
def grids.gl_instance_get_position (   instance)

Returns the position of an instance as a vector.

Parameters
instanceThe instance whose position to return.
Returns
The position of the instance as a vector.
Since
1.1
def grids.gl_instance_set_position (   instance,
  world_point 
)

Sets the position of an instance to the ggiven vector coordinates.

Parameters
instanceThe instance to move.
world_pointThe location to move the instance to (as a vector).
Since
1.1
def grids.gl_iter_create (   width,
  height,
  bottom_left,
  shape 
)

Private.

Creates a new iterator.

Parameters
width
height
bottom_left
shape
Since
1.0
def grids.gl_iter_destroy (   iter)

Destroys the given iterator.

Parameters
iterThe iterator to destroy.
Since
1.0
def grids.gl_iter_hasnext (   iter)

Returns true if the iterator has a valid next value.

See also
gl_grid_get_iter
Since
1.0
def grids.gl_iter_move (   iter)

Private.

Advances the given iterator.

Parameters
iter
Since
1.0
def grids.gl_iter_next (   iter)

Returns the next item the iterator points to, and advances the iterator.

Parameters
iter
See also
gl_grid_get_iter
Since
1.0
def grids.gl_list_add_range (   list1,
  list2 
)

Adds all the items of one list to another.

Parameters
list1The list to add the new items to.
list2The list to get new items from.

.1

def grids.gl_list_delete_point (   list,
  point 
)

Deletes the first occurance a point (vector) from a list of points.

gl_vectoor_equals is used for comparison. Generally, this should only be used for integer points.

Parameters
listA list of points.
Thepoint (a vector) to remove from the list.
def grids.gl_list_exists_point (   list,
  point 
)

Returns true if the given point is an item in the list.

Points are compared using gl_vector_equals.

Parameters
list
point
Since
1.0
def grids.gl_list_random_item (   list)

Returns a random item from a list.

Parameters
listThe list from which to return a random instance. The list must be non-empty.
Since
1.1
def grids.gl_list_sample_random (   list,
  count 
)

Returns a random sample from the given list.

Parameters
listThe list to sample.
countThe number of samples to return.
Since
1.1
def grids.gl_map_align_grid_in_rect ( )

Transforma a map so that the grid is aligned in the rectangle given.

Parameters
map
grid
window
alignment_typeOne of the constants global_gl_alignment_*.
Since
1.0
def grids.gl_map_calc_grid_extent (   map,
  grid 
)

Calculates the grids placement and size in world space.

Parameters
grid
map
Returns
a rectangle that represents the grids bottom-left corner and dimensions.
Since
1.0
def grids.gl_map_center_grid_in_rect (   map,
  grid,
  rect 
)

This is a convenience method for adjusting a map so that it will center a grid in a rectangle.

Parameters
mapThe map to modify.
gridThe grid that should be centered.
rectThe rectangle in which the grid should be centered.
Since
1.1
def grids.gl_map_closest (   map,
  world_point 
)

Returns the world point of the grid point closest to the given world point.

Useful for snapping objects to the grid.

@param map The map to use.
@param world_point The world point (as vector) to check.

@returns The world point of the grid point that contains 
the given world point.

@since 1.1 
def grids.gl_map_destroy (   map)

Destroys the given map.

Parameters
mapThe map to destroy.
Since
1.0
def grids.gl_map_distance (   map,
  grid_point1,
  grid_point2 
)

Gives the world distance between two grid points.

Parameters
mapThe map to use for the calculation. The one grid point. The other grid point.
Returns
The world distance between the two points.
Since
1.1
def grids.gl_map_flip_x (   map)

Flips a map's world X-coordinate.

Parameters
map
Since
1.0
def grids.gl_map_flip_y (   map)

Flips a map's world Y-coordinate.

Parameters
map
Since
1.0
def grids.gl_map_get_cell_dimensions (   map)

Gets the cell dimensions of the given map.

The dimensions are not transformed (scaled, for example) even if the map has been transformed (scaled).

Parameters
map
Since
1.0
def grids.gl_map_grid2rawworld (   map,
  point 
)

Does the calculation for converting grid coordinates to world coordinates.

No map transforms are incorporated.

@note Generally, this method should not be used. Rather use one of the gl_*_map_grid2world functions.

@param map The map to use for the conversion.
@param point The point to convert.

@returns The point converted to workd coordinates.

@since 1.0 
def grids.gl_map_grid2world (   map,
  grid_point 
)

Converts a grid point to a world point using the given map.

Parameters
mapThe map to use for the conversion.
grid_pointThe grid point (as vector) to convert.
Returns
The world point as vector.
Since
1.1
def grids.gl_map_magnitude (   map,
  grid_point 
)

Gives the world magnitude of a grid vector.

param map The map to use for the calculation. The grid point.

Returns
The world magnitude of the point.
Since
1.1
def grids.gl_map_rawdistance (   map,
  v1,
  v2 
)

Calculates the "raw" world distance between two grid points.

Raw means if the map has been transformed (such as scaled) those transfomrations won't be taken into acocunt.

Parameters
map
v1
v2
Since
1.0
def grids.gl_map_scale (   map,
  scale 
)

Scales the map.

Scaling the map (by value larger than 1) has the effect that cell centers are placed further apart.

Parameters
map
scaleThe amount to scale by (a non-zero number).
Since
1.0
def grids.gl_map_snap (   map,
  world_point 
)

Returns the world point of the grid point of the given world_point.

This can be used to snap positions to a grid:

1 gl_instance_set_position(obj, gl_map_snap(map, gl_instance_get_position(obj)));
Parameters
mapThe map to use for the point conversions
world_pointThe point to snap (as vector).
Returns
The snapped position (as a vector).
Since
1.1
def grids.gl_map_translate ( )

Translates a map.

This has the effect of moving all cells by the given amount.

Parameters
map
offsetA vector
Since
1.0
def grids.gl_map_world2grid (   map,
  world_point 
)

Converts a world point to a grid point using the given map.

Parameters
mapThe map to use for the conversion.
world_pointThe world point (as vector) to convert.
Returns
The grid point as vector.
Since
1.1
def grids.gl_matrix3_create (   matrix)

Creates a new matrix from the 9 given components.

Since
1.0
def grids.gl_matrix3_create_flip_x ( )

Creates a new matrix that will flip the x coordinate of a vector if that vector is multiplied with the matrix.

Since
1.0
def grids.gl_matrix3_create_flip_y ( )

Creates a new matrix that will flip the y coordinate of a vector if that vector is multiplied with the matrix.

Since
1.0
def grids.gl_matrix3_create_scale (   scale)

Creates a new matrix that denotes a scale transform.

Parameters
scale
Since
1.0
def grids.gl_matrix3_create_translation (   v)

Creates a vector that represents a translation by the given amount.

Parameters
vThe translation as a vector.
Since
1.0
def grids.gl_matrix3_identity ( )

Returns the identity matrix.

Since
1.0
def grids.gl_matrix3_inverse ( )

Returns the inverse matrix of the given matrix (provided it has one).

Parameters
mThe matrix for which to calculate the inverse for.
Since
1.0
def grids.gl_matrix3_mul (   m1,
  m2 
)

Multiplies two matrices together and returns the result as a new matrix.

Parameters
m1
m2
Returns
A matrix representing m1 multiplied with m2.
Since
1.0
def grids.gl_mouse_get_position ( )

Returns the current mouse position as a vector.

Returns
A vector containing mouse_x and mouse_y.
Since
1.1
def grids.gl_pointset_create ( )

Creates a new point set.

Since
1.0
def grids.gl_pointyhex_distance (   p1,
  p2 
)

Calculates the node-to-node distance between two pointy hex points (i.e.

how many edges you have to cross moving from one node to the other).

Parameters
p1
p2
Returns
An integer denoting the distance between the two nodes.
Since
1.0
def grids.gl_pointyhex_grid2world (   map,
  point 
)

Converts a grid point to world point using the given map.

Parameters
mapThe map to use for the conversion
pointThe point to convert
Returns
A new vector.
Since
1.0
def grids.gl_pointyhex_grid_create (   shape_label,
  size1,
  size2 
)

Creates a new pointy hex grid in a specified shape and size.

Note
You are responsible for destroying the variable using the function gl_grid_destroy
Parameters
shape_labelA string that represents the shape of the grid. The posibilities are "hexagon", "fatrectangle", "thinrectangle", and "parallelogram"
size1For most shapes, this denotes the width. For the hexagon, it denotes the side length.
size2For most figures, this denotes the height. For the hexagon, it is ignored.
Returns
A new grid.
Since
1.0
def grids.gl_pointyhex_magnitude (   p)

Gives the hex-magnitude of the given point, which is how many edges you would have to cross from the origin to the point.

Parameters
pointThe point whose magnitude to compute.
Returns
An integer.
Since
1.0
def grids.gl_pointyhex_map_create (   cell_dimensions)

Creates a new map that can be used with a pointy hex grid.

Note
You are responsible for destroying the variable using the function gl_map_destroy
Parameters
cell_dimensionsThe dimensions (as a vector).
Returns
A new map.
Since
1.0
def grids.gl_pointyhex_shape_create_fatrectangle (   width,
  height 
)

Creates a new fat rectangle (shape) in pointy hex coordinates.

Parameters
widthThe width of the rectangle in grid coordinates
heightThe height of the rectangle in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_pointyhex_shape_create_hexagon (   side)

Creates a new hexagon (shape) in pointy hex coordinates.

Parameters
sideThe length of the bexagon side grid coordinates
Returns
A new shape.
Since
1.0
def grids.gl_pointyhex_shape_create_parallelogram (   width,
  height 
)

Creates a new parallelogram (shape) in pointy hex coordinates.

Parameters
widthThe width of the parallelogram in grid coordinates
heightThe height of the parallelogram in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_pointyhex_shape_create_thinrectangle (   width,
  height 
)

Creates a new thin rectangle (shape) in pointy hex coordinates.

Parameters
widthThe width of the rectangle in grid coordinates
heightThe height of the rectangle in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_pointyhex_world2grid (   map,
  v_raw 
)

Converts a world point to a pointy hex grid point.

Parameters
mapThe map to use for the conversion.
v_rawThe world point.
Since
1.0
def grids.gl_polygon_clone (   polyogn)

Recursively clones this polygon.

Note
You are responsible for destroying the variable using the function gl_polygon_destroy
Parameters
polygon
Returns
A new polygon.
Since
1.0
def grids.gl_polygon_contains (   polygon,
  point 
)

A "polygon" is a list of halfplanes.

The polygon is interpreted as the intersection of the halfplanes, and is therefor always convex. A point is inside the polygon if it is inside all halfplanes in the list.

(Note that polygons by this definition need not be bounded).

Parameters
polygonA list of halfplanes
pointThe point to check
Returns
True if the point is inside all the halfplanes; false otherwise.
Since
1.0
def grids.gl_polygon_destroy (   polygon)

Destroys the given polygon.

Parameters
polygon(A list of halfplanes).
Since
1.0
def grids.gl_random_int (   upper_limit)

Returns a random integer between 0 (inclusive) and the given upper limit (exclusive).

Parameters
upper_limitThe upper limit of the random integer to return.
Returns
A random integer.
Since
1.1
def grids.gl_reconstruct_path (   came_from_map,
  current_node 
)

Private.

Since
1.0
def grids.gl_reconstruct_path_impl (   came_from_map,
  current_node,
  path 
)

Private.

Since
1.0
def grids.gl_rect_create (   px,
  py,
  width,
  height 
)

Creates a new rectangle.

Parameters
pxThe x-coordinate of one corner of the rectangle.
pyThe y-coordinate of one corner of the rectangle.
widthThe width of the recctangle.
heightThe height of the rectangle.

The rectangle (as a list of four numbers), an the order above.

def grids.gl_rect_destroy (   rect)

Destroys the given rect.

Since
1.0
def grids.gl_rect_distance (   p1,
  p2 
)

Calculates the node-to-node (taxicab) distance between two rect points (i.e.

how many edges you have to cross moving from one node to the other).

Parameters
p1
p2
Returns
An integer denoting the distance between the two nodes.
Since
1.2
def grids.gl_rect_get_dimensions (   rect)

Returns the dimensions of a rectangle as a vector.

Parameters
rect
Returns
The dimensions of the rectangle as a vector.
Since
1.0
def grids.gl_rect_get_endpoint (   rect)

This function returns the corner of the rectangle opposite to the corner used to construct the rectangle.

Parameters
rect
Returns
the end point as a vector.
Since
1.0
def grids.gl_rect_get_point (   rect)

Gets the corner of the rectangle used to construct the rectangle.

(The top left ocrner if the the dimensions are all positive and the coordinate axes are left-to-right and top-to-bottom.)

Parameters
rect
Returns
the point as a vector.
Since
1.0
def grids.gl_rect_grid2world (   map,
  point 
)

Converts a grid point to world point using the given map.

Parameters
mapThe map to use for the conversion
pointThe point to convert
Returns
A new vector.
Since
1.2
def grids.gl_rect_grid_create (   shape_label,
  size1,
  size2 
)

Creates a new rect grid in a specified shape and size.

Note
You are responsible for destroying the variable using the function gl_grid_destroy
Parameters
shape_labelA string that represents the shape of the grid. The posibilities are "rectangle"
size1For most shapes, this denotes the width.
size2For most figures, this denotes the height.
Returns
A new grid.
Since
1.0
def grids.gl_rect_magnitude (   p)

Gives the taxicab-magnitude of the given point, which is how many edges you would have to cross from the origin to the point (if you do not move diagonally).

Parameters
pointThe point whose magnitude to compute.
Returns
An integer.
Since
1.2
def grids.gl_rect_map_create (   cell_dimensions)

Creates a new map that can be used with a rect grid.

Note
You are responsible for destroying the variable using the function gl_map_destroy
Parameters
cell_dimensionsThe dimensions (as a vector).
Returns
A new map.
Since
1.0
def grids.gl_rect_shape_create_circle (   radius)

Creates a new circle in rect coordinates.

(The circle has the shape of a square).

Parameters
radiusThe radius of the circle.
Returns
A new shape.
Since
1.2
def grids.gl_rect_shape_create_parallelogram (   width,
  height 
)

Creates a new parallelogram (shape) in rect coordinates.

Parameters
widthThe width of the parallelogram in grid coordinates
heightThe height of the parallelogram in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_rect_shape_create_rectangle (   width,
  height 
)

Creates a new rectangle in rect coordinates.

Parameters
widthThe width of the parallelogram in grid coordinates
heightThe height of the parallelogram in grid coordinates.
Returns
A new shape.
Since
1.0
def grids.gl_rect_world2grid (   map,
  v_raw 
)

Converts a world point to a rect grid point.

Parameters
mapThe map to use for the conversion.
v_rawThe world point.
Since
1.2
def grids.gl_room_get_extent ( )

Gets the extent of the current room as a rectangle.

Returns
A rectangle with [0, 0] as one corner, and dimensions the room width and height.
Since
1.1
def grids.gl_shape_clone (   shape)

Recursively clones a shape.

Note
You are responsible for destroying the variable using the function gl_shape_destroy
Parameters
shapeThe shape to clone.
Returns
a new shape
Since
1.0
def grids.gl_shape_contains (   shape,
  point 
)

Returns true if the given shape contains the given point.

A shape is simply a list of polygons (

See also
gl_polygon_contains). The list represents the shape as a union of these polygons. It is therefor possible for the shape to not be conected. Because polygons can be unbounded, so can shapes.
Parameters
shapeA list of polygons.
point
Returns
True if the point is in any of the polygons in the list.
Since
1.0
def grids.gl_shape_create_polygon (   point_list)

Creates a new shape from a list of vertices of a convex polygon.

Since
1.2
Parameters
point_listA list of polygon vertices in anti-clockwise order.
Returns
A new shape.
def grids.gl_shape_destroy (   shape)

Destroys the given shape.

Parameters
shapeThe shape to destroy
def grids.gl_shape_union (   shape1,
  shape2 
)

Constructs a new shape that represents the union of the two shapes given.

Parameters
shape1
shape2
Returns
A new shape.
Since
1.0
def grids.gl_sprite_get_size ( )

Returns the sprite of a sprite as a vector.

Parameters
spriteThe sprite whose size to return.
Returns
The sprite size as a vector.
Since
1.1
def grids.gl_vector2str (   v)

Returns a string presentation of the given vector.

Returns
If the vector has components 0 and 3, for example, the string [0 3] is returned.
Since
1.0
def grids.gl_vector_add (   v1,
  v2 
)

Adds two vectors together and returns the sum as a new vector.

Parameters
v1
v2
Returns
A new vector.
Since
1.0
def grids.gl_vector_create (   vx,
  vy 
)

Creates a new vector from the given coordinates.

Parameters
vx
vy
Since
1.0
def grids.gl_vector_distance (   v1,
  v2 
)

Calculates the Euclidean distance between two vectors, and returns the result.

Parameters
v1
v2
returnsA real number representing the distance between the two vectors.
Since
1.0
def grids.gl_vector_dot (   v1,
  v2 
)

Returns the dot product of two vectors.

Parameters
v1
v2
Since
1.0
def grids.gl_vector_equals (   v1,
  v2 
)

Returns whether two vectors are equal, that is, if corresponding components are equal.

This method is only reliable for integer vectors (grid points).

Parameters
v1
v2
Returns
true if the vectors are equal, false otherwise.
Since
1.0
def grids.gl_vector_magnitude (   v)

Returns the Euclidean magnitude of this vector.

Parameters
v
Returns
A real number denoting the magnitude of the given vector.
Since
1.0
def grids.gl_vector_mul (   v,
  r 
)

Multiplies a vector with a real number and returns the result.

Parameters
v
r
Returns
A new vector that is the original vector multiplied with the real number.
Since
1.0
def grids.gl_vector_negate (   v)

Negates each component of this vector, and returns it as a new vector.

If you add a vector and it's negated vector, the result is the zero vector.

Parameters
v
Returns
A new vector.
Since
1.0
def grids.gl_vector_perp (   v)

Returns the new vector (-y, x), which in rect coordinates is perpendicular to the give vector.

Parameters
vThe vector whose perp vector to calculate.
Returns
A vector.
Since
1.2
def grids.gl_vector_sub (   v1,
  v2 
)

Subtracts one vector from another, and returns the result as a new vector.

Parameters
v1
v2
Returns
A new vector representing v1 - v2.
Since
1.0
def grids.gl_vector_transform (   v,
  m 
)

Multiplies a vector with a matrix, and returns the result as a new vector.

Parameters
v
m
Returns
A new vector.
Since
1.0