1
\$\begingroup\$

I have been playing story based games such as lifeline or choice of games. I was wondering what game loop best describes what's happening logically? As when mauling over it myself in my head I am trying to come up with the patterns for developing something similar and I keep hitting a brick wall. Essentially allowing for choices. Text. Variables and conditions. Some text can even be re-used with additions to condition blocks.

\$\endgroup\$
0
\$\begingroup\$

This is a super broad question. I have no idea what you want to do with the game, the only thing I can say is everything needs to be contained within a while 1 infinite loop. There's not a lot of advice to give besides that. Just don't think about it too much, actually go start programming the game and you will realize what you need as you go. I mean it's pretty clear where you will need certain loops and stuff so just start working on that.

Try starting your code off with just something like

string userInput = "";
bool quit = false;
while(!quit)
{
    Console.WriteLine("Hello, press a key to start your quest or type no to quit");
    userInput = Console.ReadLine().ToString();
    if(userInput.ToUpper() == "NO")
    {
        quit = true;
    }
    else
    {
        Console.WriteLine("Alright, moving on to the quest then!");
    }
 }

obviously this would create an infinite loop if you hit a key I'm just trying to give you the general idea.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

My partial solution to your "brick wall" is... a Node. Lots of nodes.
Something along the line of....
First node(Head node):
NodeID:1
Message:"You see a path on the left leading to a gloomy forest. You could taste the hint of the sea from the wind blowing from the right.
Options:
-Option: Title:"Go Left" TargetNodeID:2
-Option: Title:Go Right" TargetNodeID:3

after the above, develop the game loop to run based on the nodes you've created.
The actual game loop could be event based, where you press a button to load next page with little to no animation running.
Or the usual while(true) loop.
Hope it softens the "brick wall" and hope it's the correct "brick wall" we're talking about.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Make methods that seals each of the stages you have(possibly make them into a class), and a infinite loop is will be running on the Start() function along with your storyline.

Your Story class

public void stage_1()
{
    int choice = 0;
    //Do something at your stage
    if(choice == 1)
        stage_2();
    else if(choice == 2)
        stage_4();
    else
        //Something went wrong
        //By default use the first choice
        stage_2();
}
public void stage_2()
{
    int choice = 0;
    //Do something at your stage
    if(choice == 1)
        stage_3();
    else if(choice == 2)
        stage_4();
    else
        //Something went wrong
        //By default use the first choice
        stage_3();
}
public void stage_3() { //Do something at your stage }
public void stage_4() { //Do something at your stage }
//etc.

public void stage_final()
{
    //Same procedures as above
    MessageShow("Do you want to start again at the beginning?");
    if(choice == 1)
        stage_1();
    else
        end();
}

Your running script

void Start()
{
    stage_1();
}
| improve this answer | |
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.