Jump to content
  • Advertisement
Sign in to follow this  
r0yal dot net

2D RPG Maps

This topic is 3861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Hidden
I really recommend you use a binary format for this type of game. Read up on how to read and write binary data. It's pretty easy actually! You should also spend some time on writing a simple map editor application for your game, which can load your binary format, place tiles, and save it to binary again. With this kind of tool, you're going to save a lot of time and trouble. Good luck.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!