#Using ds_grids vs 2d array for tile-based room layout?

1 messages · Page 1 of 1 (latest)

brave whale
#

Hi. I'm programming something where there are 4 rooms, in a 2x2 grid, which can be rearranged like tiles or something of the sort. I would also need to save several pieces of information about each room and the objects within them.

I've never used any ds_* commands before, so this would be a big learning experience, but would 2d arrays hypothetically be easier to work with? Is there a simplified reason to use ds_grid_* over 2d arrays?

Thanks!

raven pilot
#

Because you can reasonably do operations on them much faster than a 2D array

#

Otherwise, I'd just use a 2D array

#

ds_grids don't exactly have a clean way of serializing/deserializing data (outside of the write/read functions, which even despite working okay a lot of the time, I still am skeptical of just letting GM handle that)

#

2D arrays also are just arrays

#

So you also get GC benefits from that too

#

No need to manage the 2D array cleanup yourself

brave whale
#

GC being garbage collection, I'm guessing? Also, grateful for the informative response!!

raven pilot
#

Yes

raven pilot
#

Because most of ds_grids functions do mainly apply operations on numbers

#

So if you're storing instance data or structs

#

Or anything else

#

Most of them are practically worthless

#

Arrays also do have a lot of other functionality built in too, for whatever your needs might be

brave whale
#

Very good to know. That's probably why I haven't seen many tutorials (so far) using them, since arrays can do the job in a different but more manageable way.