Showing posts with label ds_map. Show all posts
Showing posts with label ds_map. Show all posts

Sunday, November 27, 2011

GameMaker - multi-dimensional arrays

As you may know, GameMaker natively supports only 2-dimensional arrays with size up to 32000x32000.
However, in some cases, you may want to use arrays with 3 (or more) dimensions.
Small comparison table with descriptions below:

Stat\Method array:offset array:instance ds_grid's ds_map
Init (fill-up) Slow Slow Fast Slowest
Access (i/o) Fast Fast Average Average
Size limit ~109 cells 32k/dimension Resizable No
Index Integer Integer Integer String
Existance check No No Not needed Yes
Region operations No No Yes Only clearing
References No Partial (layer) Yes Yes

Tuesday, November 22, 2011

GameMaker - INI without an *.ini

So, say, you would like to load data from INI without creating an *.ini file somewhere.
There can be many reasons for doing so, be that security, performance, or simple fact of INI contents being defined inside of game's code.

There are two things to do about it - deciding on presentation of data, and creating a algorithm to load it. Presentation of data is relatively simple with INI - file is split into named sections, which contain named values. Since both use string index, using ds_map (sections) with other ds_map's inside (values) seems like an approriate choice. Below is my implementation.