Grids for Game Maker (Now on Marketplace)

edited in Projects
Hi Everyone

We have been porting a subset of our Grids library to Game Maker.

For now, it only supports hex grids, and the functionality is limited, but I think it already can be useful.

At the moment, you can only create grids in script (until I figure out how to add custom action blocks if it is at all possible). To give you an idea, here is the code for creating a simple hex grid:
// Controller Create
gl_init();

grid = gl_pointyhex_grid_create(“hexagon”, 3, 0);
map = gl_pointyhex_map_create(cell_dimensions);

var screen_rect = gl_rect_create(0, 0, 800, 600);

gl_map_align_grid_in_rect(map, grid, rect, global.gl_alignment_middlecenter);
gl_rect_destroy(rect);

var iter = gl_grid_get_iter(grid);

while(gl_iter_hasnext(iter))
{
   var point = gl_iter_next(iter);
   var world_point = gl_pointyhex_map_grid2world(point);
   var tile = gl_instance_create(tile, world_point);
   
   gl_grid_set(grid, point, tile);
}

gl_iter_destroy(iter);


It's obviously less generic than our Unity plugin, but we incorporate many if the same ideas:
  • grids are data structures similar to 2D arrays, and are indexed through points (x and y),
  • grids can be iterated
  • grids can be constructed in different shapes
  • grids can be shifted and scaled, and aligned within rectangles
  • maps provide conversion between grid points and Game Maker world points
  • we provide grid colorings (http://gamelogic.co.za/2013/12/18/what-are-grid-colorings/)
  • we provide basic algorithms for path finding, connected-shape finding, and grid point (and shape) transformations (such as rotate 60 degrees).
We had to implement quite a bit of infrastructure to make all these things possible, which should also be useful in other games:
  • 2D Vectors,
  • 3x3 matrices
  • Rectangles
  • Halfplanes
  • Convex polygons
  • Arbitrary polygons
----

Right now, we are still in prototyping phase, (but we are moving quickly!). If anyone wants to give it a try, please send me an email (herman@gamelogic.co.za). We would love some feedback! (In particular, suggestions for missing features, things that can be simplified, or that are not idiomatic to Game Maker).

----

(As an aside - I will write about it some more at some stage - but porting highly abstract C# code to Game Maker has been illuminating. It's given us an opportunity to examine the impact of a very extreme design change to the Unity plugin (we want to eliminate some of the generics), something I have been dreading for a long time. It also forced us to look at some of our design ideas, and come up with new solutions, some of which we will actually transfer to the Unity plugin too. For example, our shape presentation in the Unity plugin is internally very complex. In the Game Maker port, we discovered a much simpler presentation, which is very compact and almost as generic, and more importantly, is much simpler internally. So hopefully the effort will benefit our existing customers too :) )

Comments

Sign In or Register to comment.