Game development. Should I program my levels or interpret them from a file?

The game will be written in C ++

Programming:

enemies.puch_back(new DefaultEnemy(200, 300, 3, 5)); enemies.puch_back(new DefaultEnemy(500, 400, 4, 5)); enemies.puch_back(new DefaultEnemy(300, 420, 3, 15)); enemies.at(2).createAward(new Key(4), "pling.wav"); 

Or interpret them from a file as follows:

 DefaultEnemy 200 300 3 5 DefaultEnemy 500 400 4 5 DefaultEnemy 300 420 3 15 CreateAward 2 "pling.wav" Key 4 

The program will be simpler, and people will not be able (not to mention hacking) to edit their levels. But can it be some trash to program it all? Are there other reasons for programming or interpretation?

What about memory management (if I have to go for interpretation)?

How to delete objects (games) when a level is unloaded?

+6
c ++ interpreter
source share
4 answers

The first option is equivalent to hard coding game resources. This is absolutely bad and only suitable for debugging.

Each game stores its resources in external files - xml, archives packages and analyzes them and loads them at runtime.

Therefore, modern game engines almost every time have their own set of tools, which is bundled with it.

Removing game resources is also a huge issue - it depends . Depends on the lifecycle management of your objects and the fact if you need to unpack the data into temporary files.

+6
source share

Always separate application from data.

+11
source share

Well, I would save the level design in a file. That the script is right. It gives me a way to just change levels.

It will also store your objects (material used at levels) separately from logic (game logic). This will help debug and have a clearer structure.

+2
source share

Depending on whether you can save resources for interpretation, and who else you are going to use your work. If you and only you create it, then there is nothing wrong with hard code.

If, however, you ever intend users or anyone else to modify it, ever, then interpret.

+2
source share

All Articles