Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Implementing a storyline.  (Read 1823 times)

0 Members and 1 Guest are viewing this topic.

Forceofaqua

  • Newbie
  • *
  • Posts: 14
    • View Profile
Implementing a storyline.
« 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?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Implementing a storyline.
« Reply #1 on: December 16, 2014, 10:28:02 pm »
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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: Implementing a storyline.
« Reply #2 on: December 16, 2014, 10:28:42 pm »
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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Forceofaqua

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Implementing a storyline.
« Reply #3 on: December 17, 2014, 08:17:08 am »
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.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Implementing a storyline.
« Reply #4 on: December 17, 2014, 08:23:35 am »
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.

Forceofaqua

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Implementing a storyline.
« Reply #5 on: December 17, 2014, 08:53:57 pm »
I think I have an idea of how to start. I appreciate your reply!