123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include "Control.h"
- char key;// äëÿ ââîäà êîäà ñèìâîëà ñ êëàâèàòóðû
- char keep_direct;// äëÿ ñîõðàíåíèÿ ñèìâîëà íàïðàâëåíèÿ äâèæåíèÿ.
- //int _getch(void);// ïîëó÷àåò ñèìâîë èç êîíñîëè áåç îòîáðàæåíèÿ
- int main()
- {
- std::cout << "Press any key" << std::endl;
- do
- {
- key = _getch();
- if (key == 0 || key == -32)
- {
- keep_direct = _getch();
- switch (keep_direct)
- {
- case up: {std::cout << "up" << std::endl; }
- break;
- case down: {std::cout << "down" << std::endl; }
- break;
- case left: {std::cout << "left" << std::endl; }
- break;
- case right: {std::cout << "right" << std::endl; }
- break;
- default: {std::cout << "err404" << std::endl; }
- }
- }
- else
- {
- switch (key = toupper(key))
- {
- case 'D': {std::cout << "right" << std::endl;}
- break;
- case 'A': {std::cout << "left" << std::endl;}
- break;
- case 'W': {std::cout << "up" << std::endl;}
- break;
- case 'S': {std::cout << "down" << std::endl;}
- break;
- case '0':
- case esc: {std::cout << "out" << std::endl;}
- break;
- default: {std::cout << "err" << std::endl;}
- }
- }
- } while (key != esc && key != '0');
- return 0;//êîä çàâåðøåíèÿ ïðèëîæåíèÿ
- }
|