GPWiki.org
GPWiki.org
It is currently Mon May 20, 2013 12:08 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Oct 22, 2011 11:13 am 
Rookie

Joined: Sat Oct 22, 2011 10:57 am
Posts: 1
Here's my issue.
I need an efficient way to save, load and compress mapdata during the game (on-the-fly).
I normally use simple *.txt files for my 2D maps but i don't want to make a txt file for every floor of the map :P
In addition the maps will get quite big and i dont know if an array would be the right way to handle it in my program.
As i said the maps will get big and i assume that there will be many maps, so i want to compress them.
(And maybe later make it harder to edit from outside)

I think the map would consist of tile ids.

So:
a)How do i save a 3D map so that i can easily edit it ( 1 tile instead of the whole map)
b)How do i store/use it in my program. Array?
c)How could i compress the map file. Like RLE


Top
 Profile  
 
PostPosted: Sat Oct 22, 2011 6:58 pm 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 277
Location: Here (where else?)
Lots of options are available.

a)
What is wrong with having several files for one map, eg in a directory? Is great for debugging/testing.
For users it is less convenient, but you can use a zip or tar format to pack it into a single file.

I see no particular reason why you cannot have several floors in a single text-file either, can you elaborate why that is a bad idea?

b)
That really depends on the game. if it is all fixed size, array would be fine. You can also do it vertically, a stack at each tile position.
I would decouple the problems of map representation in a file and in memory completely, they are totally different problems with different characteristics and requirements.

c)
Use a compression algorithm that compresses the data stream on writing (and decompresses on loading).
Eg the gzip library does that.
Basically, you have a function/object that you call for each byte that you write, and the function/object decides what to write to the disk (if any). It also updates its internal administration to keep track what decisions it made in the past.


Top
 Profile  
 
PostPosted: Mon Oct 24, 2011 12:30 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
Arterie wrote:
I need an efficient way to save, load and compress mapdata during the game (on-the-fly).


Do you really need this or do you just think you need it?

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group