Answer the question
In order to leave comments, you need to log in
How to control using the keyboard?
There was a need to make control in the application via the keyboard, but I did not find anything sensible anywhere, only scraps or not quite what I need. For example, I want to control a cube through arrows. Throw some material, I will be glad :) Also, if anyone knows how to ATTEMPT to read for a certain time, well, for example, while the cube is standing, try to count the symbol / number for a second, if it is not there, then at the end of the time stop trying. Thanks in advance
Answer the question
In order to leave comments, you need to log in
snake C++ -> https://code-live.ru/post/cpp-oldschool-snake/
------------
well, you can track keystrokes in a separate thread (google: threads C++)
while(1)
{
ch = getch();
code = static_cast<int>(ch);
if(ch == 27) // если клавиша esc
exit(0);
}
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
while (1)
{
cout << "DRAW!!" << endl;
if (GetAsyncKeyState(VK_SPACE) != 0)
{
cout << "jump!" << endl;
}
_sleep(100);
}
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question