hello guyz. I have 1 problem here. I want to create boolean funqction witch asks u do u want to exit program or play again(I'm making a seample game) and while user press n(no) the program must exit. have any ideas?
2/28/2018 9:34:26 PM
Dato Khojava12 Answers
New AnswerLink the code you are having issue with here. on a new comment press [ + INSERT ] Then press [CODE] select the problem code
A few more lesson in the course will give you some of what you need. What are you using to make the game an engine? a library?
what software are you using? You need to use the close window code to exit your game. when the answer is n. that is all I can reccommend for you.
Closing a game. depends on the game library or Engine being used. - not standard C++ you cannot do stuff like that on sololearn.
I make it by myself with function and then upgreaded it with oop. Look at my codes. So u cant give me a hint how to exit the program ?
bool Replay(){ char answer; cout << "if u want play again press y else n "; cin >> answer; if( answer == 'n'){ // here i want while user press n the program must exit. } }
You can also use the “GetAsyncKeyState(‘n’)” function of the windows.h library.. like this: bool Replay(){ char answer; cout << "if u want play again press y else n "; cin >> answer; if( GetAsyncKeyState(‘n’)){ //break; || return 0 //whatever you want } This should work
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message