SFML community forums
Help => General => Topic started by: Forceofaqua on December 16, 2014, 10:23:08 pm
-
I've been working on a small project with c++, and I've run into a confusing situation. I am creating a "hacking" game, but I don't know how to implement the story. I have completed so called game engine, and will implement more as I go along, but the story is where I run into a brick wall.
The story will be linear. I need a way to create missions and sub missions. I have thought about creating a separate cpp file for each mission, but that seems like it would be a bit messy. What are some ways you have dealt with this situation?
-
Although this is a very vague question, I think I can give you the correct vague answer.
Levels should be data, and the code should be the same for every level. Typically, the data for each level would be stored in external files, and your "engine" will simply load a file each time the player starts a new level.
-
It all depends on your game play, but in the end, you most likely want to have something "scriptable", meaning you'd write "generic" classes, then load some form of mission file and set everything up as the "script" says. That way it's a lot easier to create new missions and you won't be hard coding everything into your game.
Of course getting this generality isn't the most easiest task either, but if you get it right, it most likely will make your life a lot easier.
-
Sorry for the late reply, and vague question. I just really didn't know how to word the situation of implementing a storyline. I don't want to hard code missions into the game, so I guess my question would be what is an easy way of creating missions(main and sub) so that they are not coded into the game.
-
That's not really any less vague, so I'll just repeat my previous answer: the levels/missions/content should be data rather than code. What the data looks like depends entirely on what a level/mission actually contains.
As a simple example, look at http://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php#example-tile-map. The level in this sample code is defined as a constant array of integers called "level", rather than a function that creates specific tiles in specific places. The actual code there can easily work with any array (assuming it's rectangular and all the integers are within the right range). In a real program, you would typically read these integers from a file rather than compiling them into your .exe, but the principle is the same.
-
I think I have an idea of how to start. I appreciate your reply!