Hey Everyone (and thanks for bearing over with my high amount of questions)
I have some code that i simply cannot get to work the way i intend it to, and i hope some of you might shead some light on how i could fix it.
Basically i have a setup close to this (though alot has been removed for simplicity's sake):
bool WaitForInput = false;
while(Window.IsOpened()){
sf::Event Event;
while(App.GetEvent(Event))
{
if(handler == special situation)
bool WaitForInput = true;
while(WaitForInput == true)
{
If(Event.Type == sf::Event::KeyPressed)
{
WaitForInput = false;
cout << "Key has been pressed" << endl;
}
}
}
}
So basically what i inteded with it was that if the loop enters a specific condition (the if sentance) - It should promt the user (not included in code) to press a key, and stay there until the user responds by hitting a key.
However all i've been able to achieve so far is that it gets stuck in the loop forever - despite me desperately smashing my keyboard buttons.
So is there a way to add a "wait for key input" kinda thing in the middle of the code?
(the structure of the code was kinda borrowed from
this topic.
edit: Just altered it a bit.
Moved the While Get Event part down to where my primary key input part was, as it was running the rest of the code twice whenever it recieved a valid input. (which makes no sense at all).
Also thought of a 2nd question which could be related to the first one:
As my project is "turnbased", is there a way to stop it from rushing through the while loop like a madman? As it is now it makes my cpu go from "power-saving happy" to "I diddent know you where playing 3 instances of Crysis on the highest settings" mode.
So kinda make it rest until key input (which is basically the same as i wanted in question one - except in that case it should pause-mid code).
Thanks in advance for any help!