saving data structure and reading part of data

Previous topic - Next topic

kin

If i have for example:

Code (glbasic) Select
DIM tile[10][3]

FOR x=0 TO 9
FOR y=0 TO 2
 WRITEBYTE 1,tile[x][y]
NEXT
NEXT
map:
1 0 1 0 2 0 1 0 2 2
2 0 1 0 1 1 0 1 0 0
1 0 2 0 0 2 0 2 1 0

will it be written in a data file like:
1 0 1 0 2 0 1 0 2 2 2 0 1 0 1 1 0 1 0 0 1 0 2 0 0 2 0 2 1 0
(without break)


Is there a command for reading a datafile starting from position A to B like:
            A----------------------------------.>B
1 0 1 0 2 0 1 0 2 2 2 0 1 0 1 1 0 1 0 0 1 0 2 0 0 2 0 2 1 0


btw, I want to read a selection realtime from file because it's very slow to put huge amount of data in an array.

Kitty Hello

You would have to skip the first part with a loop, that reads dummy LONGs.
It should be quite fast, still.

kin

well actually the 1st part is only for storing the whole level in a data file, a map generator.

the 2nd part is actually the game with a code that opens the datafile and read a part of it:
READBYTE 1,tile
  • [y]

But this command will put all the data in tile
  • [y]. I was wondering if you can specify which part of the data you want to read and put it into an array.

Because my mapfile contains thousands of data, I expect it to be slow to put it all into an array in the game. so I think, reading a part of the data (range A to B) realtime would be faster?

btw. range A to B is changed by player movement.

Ian Price

Using the above method should not be slow - reading or writing, even with a pretty large array.

Unless the data is really, really huge then loading it all in in one go (for each level) shouldn't take more than a blink. If it's seriously big, then it'll take forever to actually create the map in the first place!
I came. I saw. I played.