2D RPG Maps

Started by
8 comments, last by r0yal dot net 16 years, 5 months ago
Hey guys First of all thanks to everyone on this forum. I've learned a lot from these posts and it seems like any question that is thrown out there, someone will know the perfect solution. Here is a question I need you guys' advice on (if possible): I'm making a 2d rpg. I'm at the point where I'm designing the tile-based map engine. The only problem I encountered so far is the way I will load the map data. So far I only know of two options: 0. save the data in a text file 1. hard code the data into the program I don't think either option is good because if the data is in a text file, the user can just edit it and change around the maps. If it's hard coded into the game, that might be a huge waste of memory. So my question is, does anyone know a good way to store the map data? Thanks!
Advertisement
You could load them from a an encrypted file to "delay" anyone from editing the maps. You could also use resources I doubt the filesize will be much of a problem for a 2D RPG.
You can do #0 and #1 at the same time. Store your data in a text file, then store the text file in your EXE's resources (as mentioned by cNoob). Use FindResource, LoadResource, LockResource, UnlockResource and FreeResource API functions to load the text file, then process as usual.

One problem here is that each time you need to change your own map, you will have to recompile your program. Which if takes a second is not bad, but as your game becomes larger this will become a problem. I suggest you make it so that if _DEBUG is defined, your program loads maps from file system, and if the build is a release, then it loads maps from resources. And only include your maps as resources in the release build, so you don't have to wait for linker to open those map files and copy them into your exe every time.
You could always store your map data in a binary format (as opposed to a human-readable format). For example, instead of storing the characters 4 and 2 for the number 42, store the integer itself.

To do so, I would imagine that you would either use a level editor, which might write out to a binary format, or create a converter that takes human-readable map files and produces binary map files. In the former case you would presumably edit the level in the level editor, rather than in a text editor, while in the latter you might edit the level in a text editor and then convert it for use in the program (a form of mini-compilation of that file, I suppose).

If you want to go to a little more effort, you could always create some form of simple encryption, but that is probably going a little overboard.

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

I store my maps in binary files. I will eventually put them into an archive file.

Anyway, one thing you could do is to write them as text files, then write a sort of compiler (ruby's pretty good for that) that will turn them into binary files which your game can load. So, you never need to provide the text files.
Hardcode hashes of the maps into your program... they're just small strings, and associate them with a filename. Hash the map onload and if they hashes don't match... it's been tampered with.

.

If I use the binary file method, can't the user easily just download a binary->ascii converter?
Why exactly are you concerned about people editing your files?

People who like to poke around with that sort of thing will appreciate it if you have some kind of clear file format. Everyone else won't notice or care.
Quote:Original post by r0yal dot net
If I use the binary file method, can't the user easily just download a binary->ascii converter?


Yes, but embedding the maps in the exe won't stop me either.

This topic is closed to new replies.

Advertisement