Archived

This topic is now archived and is closed to further replies.

omegasyphon

question on level data

Recommended Posts

omegasyphon    100
ok i have a file called map1.dat and this file has this: level 1 1111111111 1000000001 1000000001 1000000001 1111111111 now how do i load level 1 from my map1.dat file into an array of size ar[10][5]; and also after its loaded in how do i use a case statements to draw bitmaps for each number. im using msvc++5 on win98 Edited by - omegasyphon on 7/19/00 9:25:28 AM

Share this post


Link to post
Share on other sites
Stormseeker    122
As usual, there are plenty of ways to do this but it all depends on the language. Since you didn''t mention any I can''t really give specific details. The first thing I would think of is to use simple file reading routines. With most languages, you can basically put your matrix in a file, making sure all the numbers are separated by white space, and simply read it in number by number. You just have to know before hand what the size of the matrix is or you could put the matrix size in the file as the first two numbers to be read. For example:
3 4
1 2 3 4
5 6 7 8
9 10 11 12

You could read the first two numbers, find out the matrix is 3x4 and then use for loops to read in the info into the array properly.

You don''t even need to set it up like this, just as long as there is something bewteen the numbers (whitespace usually requires the least amount of work).

As for a case statement, you could simply switch between all possible known entries in a map (You have 1''s and 0''s so the case would only have two cases). Then depending on the case block, you would put different instructions as to what bitmap to draw.

Share this post


Link to post
Share on other sites