How can I make the text appear slowlier?

I think that my game would be even more epic if I just make the text appear in a slowlier way and I don’t know how to do that. Thank you!

An I have another question: How can I make that the game stops when the answer of the player is wrong?

Is this bulls and cows?

I think that my game would be even more epic if I just make the text appear in a slowlier way and I don’t know how to do that. Thank you!

That’s kind of more anvanced programming to do it well so I’m going to give you some easier ideas that as I also want you to do the work.

You could do something like a for and while loop or two while loops, etc using a very high count… depending on the number and the hardware it will take longer. Then you just output one character at the beginning of the while loop and it waits until the next loop finishes. This consumes the thread however and isn’t good.

You could also output one character and have user press a key like the spacebar to get each.

To do it properly, you would need, at a minimum, a timer. One way is to put it on a background thread and wait for x about of time outputting one character for each loop. I’m sure there’s other ways.

Example https://www.geeksforgeeks.org/timer-c-using-system-calls/

The problem with the example is that nothing else can be done while its looping. You can’t be doing anything else while its running. Threading and other things can open up the to still allow the user to use the program. At least here, its not a big deal.

An I have another question: How can I make that the game stops when the answer of the player is wrong?

Depends at which point you’re at. If finished, you can just break from the while loop used to play game using if check on correct answer bool.

Sorry, I was refering to TripleX.

Still the same as what I typed above.

To add to the 2nd quote (I do this for you now but that’s all),

    if (bLevelComplete) 
    {
        ++LevelDifficulty;
    }
    else
    {
        break; // Exit game when answer is wrong
    }

or because its using (LevelDifficulty <= MaxDifficulty)…

    else
    {
        LevelDifficulty = MaxDifficulty + 1; // Exit game when answer is wrong
    }

or you can even do this…

   while ((LevelDifficulty <= MaxDifficulty) && bLevelComplete) // Also exits game when answer is wrong
   {...}

But don’t get into the habit of being one of those people who tries to get all code being done for you. That’s not a good programmer. You learn nothing by copy/pasting and moving on.

loops… break; will exit loop, continue; will skip to next loop iteration (skipping anything below it and so is used to do that).

functions… return; or return [function return type with value]; will return from a function where ever you have it called.

These are important to control code execution and are excellent to know :slight_smile:

Its better if you take the examples and make it into your own thing.

Privacy & Terms