Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 like this:

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

Program it would be more easy and people can't (without speaking of hacking) edit your levels. But it maybe a bit rubbish to program it all? Are there other reasons to choose for programming or interpreting?

How about memory-management (if I should go for interpreting)?

How to delete the (game)objects when the level unloads?

like image 665
Martijn Courteaux Avatar asked Jun 19 '10 19:06

Martijn Courteaux


People also ask

Should I learn C# or C++ first for game development?

Both C# and C++ can be used to create games. However, C++ has better control hardware on the PC or server. Therefore, it is usually a more suitable language for game development.

Is C or C++ better for game development?

Direct code compilation provides better code performance, making games more efficient with a faster gaming experience. Differences Unlike C#, C++ is efficient in dealing with low-level C and assembly languages, making games developed in C++ relatively faster.

Is C++ enough for game development?

C++ is an excellent programming language for game development. Its low-level language components give you the freedom to manipulate hardware and ensure a highly responsive gaming experience. While higher-level languages are faster to write in, they don't give you the flexibility and performance that C++ provides.

Is coding necessary for game development?

To become a game developer, one is required to have good coding skills, for which a basic knowledge of physics and maths is important.


3 Answers

Always separate application from data.

like image 73
Konerak Avatar answered Oct 31 '22 16:10

Konerak


First variant is equivalent to hardcoding game resources. This is absolutely bad and is suitable only for debugging.

Every games store their resources in external files - xml, archived packages and parse and load them during runtime.

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

Deleting game resources is also a vast question - it depends. Depends on your objects' lifetime management and on that fact if you need to unpack your data into temporal files.

like image 6
M. Williams Avatar answered Oct 31 '22 17:10

M. Williams


Well I would save the level design in a file. Thats what scripting is for right. This then gives me a way to JUST change the levels..

Also It will keep your objects (the stuff used in the levels) seperate from the logic (the game logic). This will help debugging and have a clearer structure

like image 2
Laz Avatar answered Oct 31 '22 18:10

Laz