Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Are you loading the file from a remote server? If so, that's why it's taking so long. Instead you should embed the file into the game. I'm saying this because you probably take 2-3 bytes per tile, so the file's about 30kb and 200ms sounds like a reasonable download time for that size of file (including overhead etc, and depending on your internet connection).</p> <p>Regarding how to lower the filesize - there are two easy techniques I can think of that will decrease the filesize a bit:</p> <p>1) If you have mostly empty squares and only some significant ones, your map is what is often referred to as 'sparse'. When storing a sparse array of data you can use a simple compression technique (formally known as 'run-length encoding') where each time you come accross empty squares, you specify how many of them there are. So for example instead of {0,0,0,0,0,0,0,0,0,0,1,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,1} you could store {10 0's, 1, 1, 2, 3, 12 0's, 1}</p> <p>2) To save space, I recommend that you store everything as binary data. The exact setup of the file mainly depends on how many possible tile types there are, but this is a better solution than storing the ascii characters corresponding to the base-10 representation of the numers, separated by delimiters.</p> <hr> <h2>Example Binary Format</h2> <ul> <li><p>File is organized into segments which are 3 or 4 bytes long, as explained below.</p></li> <li><p>First segment indicates the version of the game for which the map was created. 3 bytes long.</p></li> <li><p>Segments 2, 3, and 4 indicate the dimensions of the map (x, y, z). 3 bytes long each.</p></li> <li><p>The remaining segments all indicate either a tile number and is 3 bytes long with an MSB of 0. The exception to this follows.</p></li> <li><p>If one of the tile segments is an empty tile, it is 4 bytes long with an MSB of 1, and indicates the number of empty tiles including that tile that follow.</p></li> </ul> <p>The reason I suggest the MSB flag is so that you can distinguish between segments which are for tiles, and segments which indicate the number of empty tiles which follow that segment. For those segments I increase the length to 4 bytes (you might want to make it 5) so that you can store larger numbers of empty tiles per segment.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload