So I have a problem. I am a new C++ coder, and I've been trying to make a text based game recently (I heard it was simple). But I've always ended up with a bunch of if-statements, while loops, etc., making it very hard to read.
Is there any better way of formatting your code? And if so, could I use an alternative function to help me with organization?
Here is what my code looks like (it goes on and on looking like this):
if (action == 1)
{
cout << "You have passed! What do you do?" << endl;
cin >> action;
if (action == 1)
{
cout << "Correct!" << endl;
}
else
{
cout << "Wrong!" << endl;
}
}
else
{
cout << "You have failed!" << endl;
}
Aucun commentaire:
Enregistrer un commentaire