Hello i was wondering about how i could make a loop that like runs on the same time
Code:while(1)
{
if m=1
cout << "lol";
}
while(1)
{
if get_key(space)
m=1;
else
m=0;
}
remember this is just a example!
Printable View
Hello i was wondering about how i could make a loop that like runs on the same time
Code:while(1)
{
if m=1
cout << "lol";
}
while(1)
{
if get_key(space)
m=1;
else
m=0;
}
remember this is just a example!
would you please explain more! ? it somehow vague to me !(an possibly the others)
you mean you are planning to make an infinite loop?
it seems you'd like to do 2 things simultaneously.
two ways:
1. use threads
2. use asynchronous processing (for example timers)
Or perhaps you could use non-blocking input (OS-specific).
So is your goal to write 'lol' while the spacebar is held down?
If so, you need to use an input method that doesn't wait for you to press a key, but instead just returns the answer immediately telling you if the key is currently down or not. That's "non-blocking input".
Then you only have one loop. Pseudocode:Of course you shouldn't make a busy-loop like this though.Code:while (true)
{
if (key_is_down(KEY_SPACEBAR))
cout << "lol";
}