The bool variable in the main function is unnecessary - try this instead for more readability and less clutter

int main()
{
do {
PrintIntro();
PlayGame();
} while (AskToPlayAgain());
return 0;
}

braisbr1,
My code only prints it once and works fine, though you havent shared your code with me, I can assume that the reason you are getting this is because you are calling AshToPlayAgain() function somewhere prior to the while condition or are duplicating the print elsewhere in your code. If you only call the function a single time within the while statement, you will only see it printed once, and the return value will go straight into the while condition without using a “middle-man” variable, which in this case may not be a big deal either way however when working with a limited amount of memory, or if you are calling a function several hundred/thousand times in a game or other project, the use of memory can add up and cause performance issues down the road.

That being said, I have since finished section 2 of the course and I am an experienced java coder so if you run into any problems, have any questions, or would like to see alternative ways of doing what they do in the lectures, please contact me and I’d be happy to help.

Since starting this course I havent really been in contact with anyone and in my 4 years of coding I have found that these things are much more fun and interesting when working with others.

-Brandon Steel

Hi Brandon!

Thanks for your answer, I deleted my previous one as minutes after I posted my reply I realised that the reason for my code working funny was the exact same thing you’ve said - I had the function both on the “while” condition as well as in the main body of the Do. So I understood my own error and deleted the original reply - your method works beautifully.

I haven’t been in contact with anyone in particular as well since starting this course - happy to keep in touch for whatever may come along in this course or any other reason :slight_smile: I don’t have much experience coding, except for a good 3 years with Unreal’s own Blueprint System, so I’m having a lot of fun as coding is something I’ve always wanted to do.

Cheers and keep it up!

Brais

Well just as you are new to coding, I am new to UE4 so we can certainly help each others out.
Best of luck

Privacy & Terms