New Functions In Early Access (GMS v1.3+)

Our senior developer Mike Dailly has been busy re-doing the draw pipeline to make all platforms consistent (see the tech blog article Changes to the GUI layer, and the new Application Surface), but he's also found the time to add in some extra user-requested functions to the Early Access build of GameMaker: Studio. These new functions are generally simple additions to GML designed to make your programming life easier, and although they are in the Early Access builds, they will be brought over to the normal GameMaker: Studio version in a future update.

This short article aims to give you a brief over-view of these functions to bring them to your attention (since, let's be honest, who reads the release notes!?), but they are all documented with more depth and with examples of use in the Early Access version manual.

The Functions

angle_difference(src, dest)

This function has been much requested and is incredibly useful for easily creating smooth rotation between two points, as well as many other things. It takes a source angle and a destination angle and will return the smallest angle difference between them as a value between -180 and 180.

 

dsin(angle)
dcos(angle)
dtan(angle)
darcsin(x)
darccos(x)
darctan(x)
darctan2(y, x)

Since most of the angle related functions and variables in GameMaker: Studio use degrees, a common complaint from users has been that the trigonometric functions don't, Meaning that you have to have degree>radian>degree conversions in your code. However that is no longer the case and all the above functions are versions of the standard functions, only they take degrees as their argument values.

 

ds_list_add(id, val1 [,val2, ... val15])
ds_queue_enqueue(id, val [,val2, ... val15])
ds_stack_push(id, val [,val2, ... val15])

While the above functions for data structures are not new additions, they have been "tweaked". Previously if you had to add (for example) 10 items into a ds_list, you would have to have used the ds_list_add() function ten times. Now, however, the function takes variable arguments, meaning that for stacks, maps and lists, you can add up to 15 items in a single call.

 

tile_get_count()
tile_get_id(index)
tile_get_ids()
tile_get_ids_at_depth(depth) 

Tile handling is another area that many users have requested be added to, and with these new functions it is hoped that using and changing tiles from code will become easier and more accessible. Basically, you can now get a count of all tiles in a single room, then iterate through them all one at a time to get the unique id for the individual tile which can then be modified. You can also get a pre-populated array of tile ids for all depths, or an array of ids for those tiles at a specific depth.

 

point_in_rectangle(px, py, x1, y1, x2, y2)
point_in_triangle(px, py, x1, y1, x2, y2, x3, y3)
point_in_circle(px, py, cx, cy, rad)

rectangle_in_rectangle(sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2) rectangle_in_triangle(sx1, sy1, sx2, sy2, x1, y1, x2, y2, x3, y3) rectangle_in_circle(sx1, sy1, sx2, sy2, cx, cy, rad)

The functions listed above are all extra collision checking functions designed to make life easier when dealing with objects and interfaces that either don't have sprites or that require non-mask based approached to collisions. The first set will check to see if a specific point is within the defined area, returning either true or false, while the second set check for an area overlap with the chosen form. These area functions will return either 0, 1, or 2, where 0 is no collision, 1 is a complete overlap (ie: the defined area is completely within the shape) while a 2 means there is only a partial overlap.

 

draw_roundrect_ext(x1, y1, x2, y2, radx, rady, outline)
draw_roundrect_color_ext(x1, y1, x2, y2, radx, rady, col1, col2, outline)

These two functions simply extend the functionality of the round rectangle drawing functions, permitting you to set an x and y radius for the corners, giving you more control over the final "look" of the rectangle being drawn. Very useful for interface design and custom text-boxes etc...

 

mp_grid_get_cell(id, x, y)

The current mp_grid functions permit you to set individual cells in a motion planning grid, as well as clear them, but in many cases you'd like to know whether a cell is "flagged" or not and there was no way to do this. However this function rectifies this omission and lets you check a cell to see if it has been marked on the grid as occupied (in which case the function returns true), or not (false).

 

window_device()

The final function in this list is primarily for those of you that make Windows extensions (and is only for Windows). It will return the d3d device "handle", which you can then pass through to your dll to get access to the draw pipeline.

 

That's it for this round-up of new, minor, functions that have been added. We hope that these help you get more from GameMaker: Studio and that they make your life as a programmer that little bit easier!

Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk