I writing simple cmd game. My question is how to use timing function while I use _getch() command? Because this getch function stops the timing and the timer continuous after I click the keys.:@
sasho648
0
Newbie Poster
Recommended Answers
Jump to PostYou're entering the realm of concurrency. For example, you might create one thread to handle user input while another handles the timer.
Jump to PostOk that's looks simple but how?
I wish concurrency were simple.
Can you post an example code?
Sure. With this example I'm assuming your "timer" is actually a timeout for the input. That seems to be the more common situation relative to an ongoing timer separate from the input loop. …
Jump to PostWhile multithreading is indeed the way to go in such cases, I believe the OP might be able to get away with just a
_kbhit
call.#include <windows.h> #include <conio.h> #include <iostream> int main() { int counter = 0; char ch = 0; while (true) { …
All 10 Replies
Narue
5,707
Bad Cop
Team Colleague
sasho648
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
sasho648
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
m4ster_r0shi
142
Posting Whiz in Training
sergent
commented:
much easier then Narue's. Same thing I had in mind!
+5
Narue
5,707
Bad Cop
Team Colleague
iamthwee
DestinyChanger
0
Newbie Poster
sasho648
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.