|
-
Jul 31st, 2001, 07:16 PM
#1
Thread Starter
Member
Storing Maps ... Simple Question
I am planning on storing game maps to a text file. Each
of my hexes has a value (1024 possible for each) .
So, the map will have a height and width in hexes and
then I will read the map array one value at a time to
the text file.
There will be any number of maps available with different
sizes. The player can choose, edit or create them.
How do you guys go about this?
Thanks
-
Jul 31st, 2001, 07:56 PM
#2
transcendental analytic
Easiest as well as most efficient way to go is to store the maps binary as a single type,ex:
Code:
Type mapfile
map() as mapdata
end type
Type mapdata
data() as integer
End type
...
dim data as mapfile
...
put#1,,data
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 31st, 2001, 08:29 PM
#3
Thread Starter
Member
Thanks kedaman
I was trying to do that earlier but was failing miserably.
I need to get the hang of random file access.
Anyway, I'll figure it out. Just need to find a few more
examples. How come its only the simple things that
beat me up?
Thanks again
Its good to know what the proes do.
-
Jul 31st, 2001, 10:05 PM
#4
Member
Keger ... Look up info on "Binary Files", not "Random Access" ...
In its most basic form, you open one for writing like this:
Code:
Dim FileNum as Integer
FileNum = FreeFile
Open "myfile.dat" for Binary Access Write as #FileNum
There's info in the VB help file about how to lock the file as well as other options.
Then, to write data to the file, you simply use
Code:
Put #FileNum, 1, Data
That number (1, in the above example) is what byte of the file to start writing ... The nice thing about it is that you can write entire arrays of whatever type you wish with a single statement.
Then, to read the file open it with "Access Read" and use Get # to retrieve things ...
Hope that gets you started.
-Bryk
-
Aug 1st, 2001, 07:23 PM
#5
Thread Starter
Member
-
Aug 1st, 2001, 07:49 PM
#6
transcendental analytic
You can put an array in one shot, but the dimensions won't store, unless you do it manually. As I suggested carefully planning a tree of UDT's as a header for the file contents, you can put the whole UDT in one shot without any fuss about other datatypes.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 1st, 2001, 08:36 PM
#7
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|