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!
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?
Highlight Your Codes
The Boost C++ Libraries (online Reference)
Bill Bryson"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
it seems you'd like to do 2 things simultaneously.
two ways:
1. use threads
2. use asynchronous processing (for example timers)
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Or perhaps you could use non-blocking input (OS-specific).
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
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"; }
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"