0
\$\begingroup\$

I'm making a map in an array, something like this :

mapa[23,26]=4;mapa[25,28]=3;mapa[21,28]=3;mapa[22,30]=3;mapa[24,30]=0;
mapa[22,27]=5;mapa[23,27]=0;mapa[24,27]=0;
mapa[22,28]=1;mapa[23,28]=0;mapa[24,28]=0;
mapa[22,29]=0;mapa[23,29]=0;mapa[24,29]=0;
mapa[23,33]=0; mapa[23,32]=0; mapa[23,31]=0;mapa[23,30]=0;

This is tedious. In other languages 2d arrays can be written like :

int[][] myArray = {  {0, 1, 2, 3},
                     {3, 2, 1, 0},
                     {3, 5, 6, 1},
                     {3, 8, 3, 4}  };

Can I write in Game Maker Studio 2Darrays like this?

\$\endgroup\$
1
\$\begingroup\$

I strongly suggest keeping as many resources/data in files rather than hard-coded/compiled into executable.
For example, the csv format should be suitable for storing data simple as like 2D arrays of integers are and there should not be any problems finding a csv reader for GameMaker or implement csv reader yourself easily(+-20 lines)

mapa.txt:
0, 1, 2, 3
3, 2, 1, 0
3, 5, 6, 1
3, 8, 3, 4
//MUCH cleaner and flexible code 
mapa = loadCSV(mapa.txt); //loadCSV not part of gamemaker, need to download/implement
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy