0
\$\begingroup\$

I am creating a maze game in c++. I have a class that is used to create the walls with positioning and collision. I want the user to have the capability to include the header files needed for making the walls into a separate map file, and then be able to upload that file to the game without having to recompile the game itself. Should these map files be separate .exe or some other compiled file? could they be regular .cpp files that the game just reads? A friend suggested dynamic libraries, but that doesn't seem quite right.

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

Most games put their map data into separate files. The game executable reads and parses these files at runtime. Read up on how to do file input in C++. You can then invent your own file format.

If you are looking for a solution which allows easy editing with the minimum amount of programming necessary, then you could use a text-based format where every map tile is one character. That makes it possible to create and edit maps with a text editor.

If you want to make map editing even easier or if you can't cover the whole feature set of your game with one character per tile, then you could program your own map editor, either as a separate feature of your game or as a stand-alone application. Or you could use an existing map editor like Tiled. You can load the Tiled map format (.tmx) in a C++ game with the library libtiled.

\$\endgroup\$
2
\$\begingroup\$

Looks like you are hardcoding the map of your game within your exe.

Don't do that.

Put the map data in text files, which will be read by your game at level start up.

There are no standard for this so you'll have the freedom to customize your map file format to your needs.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .