Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.40 KB | None | 0 0
  1. #include <chrono>
  2. #include <ctime>
  3. #include <fstream>
  4. #include <iostream>
  5. #include <map>
  6. #include <mutex>
  7. #include <string>
  8. #include <thread>
  9. #include <utility>
  10. #include <windows.h>
  11. #include <vector>
  12. #include <mmsystem.h>
  13. #include <stdlib.h>
  14. #pragma comment(lib, "winmm.lib")
  15.  
  16. void setcursor(bool visible) // set bool visible = 0 - invisible, bool visible = 1 - visible
  17. {
  18. HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  19. CONSOLE_CURSOR_INFO lpCursor;
  20. lpCursor.bVisible = visible;
  21. lpCursor.dwSize = 20;
  22. SetConsoleCursorInfo(console, &lpCursor);
  23. }
  24.  
  25.  
  26. int dir = 4;
  27. int num = 1;
  28.  
  29. int hight = 15;
  30. int weight = 40;
  31.  
  32. #pragma region first
  33.  
  34. std::mutex cout_mutex;
  35.  
  36. int a = 0; //10-exit 3- sleep
  37.  
  38. struct cursor_position
  39. {
  40. int x;
  41. int y;
  42. };
  43.  
  44. void setpos(cursor_position position)
  45. {
  46. COORD pos;
  47. pos.X = position.x;
  48. pos.Y = position.y;
  49. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
  50. }
  51.  
  52. cursor_position getpos()
  53. {
  54. CONSOLE_SCREEN_BUFFER_INFO sbi;
  55. GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &sbi);
  56.  
  57. return { sbi.dwCursorPosition.X, sbi.dwCursorPosition.Y };
  58. }
  59.  
  60. void setcol(int col)
  61. {
  62. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), col);
  63. }
  64.  
  65. template <typename message_type>
  66. void write_to_stream(const message_type message,int col, cursor_position position = { -1, -1 })
  67. {
  68. std::lock_guard<decltype(cout_mutex)> locker(cout_mutex);
  69.  
  70. if (position.x == -1 || position.y == -1)
  71. {
  72. std::cout << message;
  73. return;
  74. }
  75.  
  76. auto prev_pos = getpos();
  77. setpos(position);
  78. setcol(col);
  79. std::cout << message;
  80. setcol(7);
  81. setpos(prev_pos);
  82. }
  83.  
  84. void cls(HANDLE hConsole)
  85. {
  86. std::lock_guard<decltype(cout_mutex)> locker(cout_mutex);
  87.  
  88. COORD coordScreen = { 0, 0 }; // home for the cursor
  89. DWORD cCharsWritten;
  90. CONSOLE_SCREEN_BUFFER_INFO csbi;
  91. DWORD dwConSize;
  92.  
  93. // Get the number of character cells in the current buffer.
  94.  
  95. if (!GetConsoleScreenBufferInfo(hConsole, &csbi))
  96. return;
  97. dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
  98.  
  99. // Fill the entire screen with blanks.
  100.  
  101. if (!FillConsoleOutputCharacter(hConsole, (TCHAR)' ', dwConSize, coordScreen, &cCharsWritten))
  102. return;
  103.  
  104. // Get the current text attribute.
  105.  
  106. if (!GetConsoleScreenBufferInfo(hConsole, &csbi))
  107. return;
  108.  
  109. // Set the buffer's attributes accordingly.
  110.  
  111. if (!FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
  112. return;
  113.  
  114. // Put the cursor at its home coordinates.
  115.  
  116. SetConsoleCursorPosition(hConsole, coordScreen);
  117. }
  118. void first_menu(int choice);
  119. void second_menu(int counter);
  120. void thrid_menu(int choice, int counter);
  121. void rules();
  122. void table_for_menu();
  123. void paint_the_flovers();
  124. void easy_english_test();
  125. void normal_english_test();
  126. void hard_english_test();
  127. void dictionary();
  128. void easy_math_test();
  129. void normal_math_test();
  130. void hard_math_test();
  131. void theory();
  132. void easy_bio_test();
  133. void normal_bio_test();
  134. void hard_bio_test();
  135. void theory_bio();
  136.  
  137. class english
  138. {
  139. public:
  140. void first_english_menu()
  141. {
  142. int choice_en = 0, counter_en = 0;
  143. HANDLE hStdout;
  144. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  145. while (true)
  146. {
  147. switch (choice_en)
  148. {
  149. case 80:
  150. {
  151. counter_en++;
  152. if (counter_en > 4)
  153. counter_en = 0;
  154. break;
  155. }
  156. case 72:
  157. {
  158. counter_en--;
  159. if (counter_en < 0)
  160. counter_en = 4;
  161. break;
  162. }
  163. case 13:
  164. {
  165. thrid_english_menu(counter_en);
  166. break;
  167. }
  168. }
  169. cls(hStdout);
  170. second_english_menu(counter_en);
  171. choice_en = _getwch();
  172. }
  173. }
  174.  
  175. protected:
  176.  
  177. void second_english_menu(int choice_en)
  178. {
  179. table_for_menu();
  180. char variant[5][11] = { "Easy", "Normal", "Hard", "Dictionary", "Exit" };
  181. write_to_stream("MENU",3, { 10, 2 });
  182. for (int i = 0; i < 5; i++)
  183. {
  184. if (i == 0)
  185. write_to_stream(" ", 7, { 8, 3 + i });
  186. if (i == choice_en)
  187. {
  188. for (int j = 0; j < strlen(variant[i]); j++)
  189. {
  190. write_to_stream(" ", 3, { 8+j, 3 + i });
  191. write_to_stream(variant[i][j], 3,{ 8+j, 3 + i });
  192. }
  193. }
  194. else
  195. {
  196. for (int j = 0; j < strlen(variant[i]); j++)
  197. {
  198. write_to_stream(" ", 7, { 8+j, 3 + i });
  199. write_to_stream(variant[i][j], 7, { 8+j, 3 + i });
  200. }
  201. }
  202. write_to_stream("\n",7);
  203. }
  204. }
  205.  
  206. void thrid_english_menu(int counter_en)
  207. {
  208. bool exit = true;
  209. while (exit)
  210. {
  211. switch (counter_en)
  212. {
  213. case 0:
  214. {
  215. HANDLE hStdout;
  216. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  217. cls(hStdout);
  218. bool exit_0 = true;
  219. while (exit_0)
  220. {
  221. a = 10;
  222. easy_english_test();
  223. write_to_stream("\nyou was win easy level\nif you want to exit, press \"escape\"\n",12);
  224. if (_getwch() == 27)
  225. {
  226. exit_0 = false;
  227. cls(hStdout);
  228. int choice = 0, counter = 0;
  229. second_english_menu(choice);
  230. choice = _getwch();
  231. cls(hStdout);
  232. first_english_menu();
  233. }
  234. else if (_getwch() != 27)
  235. cls(hStdout);
  236. a = 0;
  237. }
  238. break;
  239. }
  240. case 1:
  241. {
  242. HANDLE hStdout;
  243. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  244. cls(hStdout);
  245. bool exit_1 = true;
  246. while (exit_1)
  247. {
  248. normal_english_test();
  249. write_to_stream("normal\nif you want to exit, press \"escape\"\n",7);
  250. if (_getwch() == 27)
  251. {
  252. exit_1 = false;
  253. cls(hStdout);
  254. int choice = 0, counter = 0;
  255. second_english_menu(choice);
  256. choice = _getwch();
  257. cls(hStdout);
  258. first_english_menu();
  259. }
  260. else if (_getwch() != 27)
  261. cls(hStdout);
  262. }
  263. break;
  264. }
  265. case 2:
  266. {
  267. HANDLE hStdout;
  268. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  269. cls(hStdout);
  270. bool exit_2 = true;
  271. while (exit_2)
  272. {
  273. hard_english_test();
  274. write_to_stream("hard\nif you want to exit, press \"escape\"\n",7);
  275. if (_getwch() == 27)
  276. {
  277. exit_2 = false;
  278. cls(hStdout);
  279. int choice = 0, counter = 0;
  280. second_english_menu(choice);
  281. choice = _getwch();
  282. cls(hStdout);
  283. first_english_menu();
  284. }
  285. else if (_getwch() != 27)
  286. cls(hStdout);
  287. }
  288. break;
  289. }
  290. case 3:
  291. {
  292. HANDLE hStdout;
  293. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  294. cls(hStdout);
  295. bool exit_3 = true;
  296. while (exit_3)
  297. {
  298. dictionary();
  299. write_to_stream("dictionary\nif you want to exit, press \"escape\"",7);
  300. if (_getwch() == 27)
  301. {
  302. exit_3 = false;
  303. int choice = 0, counter = 0;
  304. cls(hStdout);
  305. second_english_menu(choice);
  306. choice = _getwch();
  307. cls(hStdout);
  308. first_english_menu();
  309. }
  310. else if (_getwch() != 27)
  311. cls(hStdout);
  312. }
  313. break;
  314. }
  315. case 4:
  316. {
  317. exit = false;
  318. HANDLE hStdout;
  319. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  320. cls(hStdout);
  321. int choice = 0, counter = 0;
  322. first_menu(choice);
  323. choice = _getwch();
  324. cls(hStdout);
  325. thrid_menu(choice, counter);
  326. break;
  327. }
  328. default:
  329. break;
  330. }
  331. }
  332. }
  333. };
  334.  
  335. void easy_english_test()
  336. {
  337. HANDLE hStdout;
  338. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  339. a = 3;
  340. SetConsoleCP(1251);
  341. SetConsoleOutputCP(1251);
  342.  
  343. std::map<std::string, std::string>m
  344. {
  345. {"яблуко","apple"},
  346. {"лимон","lemon"},
  347. {"картопля","potato"},
  348. {"вино","wine"},
  349. {"м'ясо","meat"}
  350. };
  351.  
  352. std::string arrW[5]= { "яблуко","лимон","картопля","вино","м'ясо" };
  353.  
  354. int attempt = 0;
  355.  
  356. cls(hStdout);
  357. while (attempt !=5)
  358. {
  359. write_to_stream("uk word: ",7);
  360. std::string word;
  361. std::string h_word;
  362. word = arrW[attempt];
  363. write_to_stream(word,7);
  364. auto f = m.find(word);
  365.  
  366. write_to_stream("\nEnter transtale: ",7);
  367. std::cin >> h_word;
  368. cls(hStdout);
  369. if (h_word == (*f).second)
  370. {
  371. write_to_stream((*f).first, 3);
  372. write_to_stream(" - ", 12);
  373. write_to_stream((*f).second, 3);
  374. write_to_stream("\ncorrect\n", 12);
  375. }
  376. else
  377. {
  378. write_to_stream("not correct translate, try again\n", 12);
  379. attempt--;
  380. }
  381. attempt++;
  382. }
  383. a = 0;
  384. SetConsoleCP(866);
  385. SetConsoleOutputCP(866);
  386. }
  387.  
  388. void normal_english_test()
  389. {
  390. HANDLE hStdout;
  391. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  392. a = 3;
  393. SetConsoleCP(1251);
  394. SetConsoleOutputCP(1251);
  395.  
  396. std::map<std::string, std::string>m
  397. {
  398. {"добрий"," kind"},
  399. {"щедрий" ,"generous"},
  400. {"скупий", "mean"},
  401. {"щасливий","chearful"},
  402. {"нещасний","miserable"},
  403. {"напружений","tense"},
  404. {"безтурботний","easy-going"},
  405. {"сильний","strong"},
  406. {"слабкий","weak"},
  407. {"чесний","honest"}
  408. };
  409.  
  410. std::string arrW[10] = { "добрий","щедрий","скупий","щасливий","нещасний","напружений","безтурботний","сильний", "слабкий" ,"чесний" };
  411.  
  412. int attempt = 0;
  413.  
  414. cls(hStdout);
  415. while (attempt != 10)
  416. {
  417. write_to_stream("uk word: ", 7);
  418. std::string word;
  419. std::string h_word;
  420. word = arrW[attempt];
  421. write_to_stream(word, 7);
  422. auto f = m.find(word);
  423.  
  424. write_to_stream("\nEnter transtale: ", 7);
  425. std::cin >> h_word;
  426. cls(hStdout);
  427. if (h_word == (*f).second)
  428. {
  429. write_to_stream((*f).first, 3);
  430. write_to_stream(" - ", 12);
  431. write_to_stream((*f).second, 3);
  432. write_to_stream("\ncorrect\n", 12);
  433. }
  434. else
  435. {
  436. write_to_stream("not correct translate, try again\n", 12);
  437. attempt--;
  438. }
  439. attempt++;
  440. }
  441. a = 0;
  442. SetConsoleCP(866);
  443. SetConsoleOutputCP(866);
  444. }
  445.  
  446. void hard_english_test()
  447. {
  448. HANDLE hStdout;
  449. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  450. a = 3;
  451. SetConsoleCP(1251);
  452. SetConsoleOutputCP(1251);
  453.  
  454. std::map<std::string, std::string>m
  455. {
  456. {"красивий","handsome"},
  457. {"борода" ,"beard"},
  458. {"мила", "pretty"},
  459. {"привабливий","atractive"},
  460. {"гидкий","ugly"},
  461. {"ніякий","plain"},
  462. {"високий","tall"},
  463. {"стрункий","slim"},
  464. {"товстий","fat"},
  465. {"мускулистий","muscular"},
  466. {"худий","thin"},
  467. {"жахливо","terribly"},
  468. {"кістлявий","skinny"},
  469. {"блідий","pale"},
  470. {"шрам","scar"}
  471. };
  472.  
  473. std::string arrW[15] = { "красивий","борода","мила","привабливий","гидкий","ніякий","високий","стрункий", "товстий" ,"мускулистий","худий","жахливо","кістлявий","блідий","шрам" };
  474.  
  475. int attempt = 0;
  476.  
  477. cls(hStdout);
  478. while (attempt != 15)
  479. {
  480. write_to_stream("uk word: ", 7);
  481. std::string word;
  482. std::string h_word;
  483. word = arrW[attempt];
  484. write_to_stream(word, 7);
  485. auto f = m.find(word);
  486.  
  487. write_to_stream("\nEnter transtale: ", 7);
  488. std::cin >> h_word;
  489. cls(hStdout);
  490. if (h_word == (*f).second)
  491. {
  492. write_to_stream((*f).first, 3);
  493. write_to_stream(" - ", 12);
  494. write_to_stream((*f).second, 3);
  495. write_to_stream("\ncorrect\n", 12);
  496. }
  497. else
  498. {
  499. write_to_stream("not correct translate, try again\n", 12);
  500. attempt--;
  501. }
  502. attempt++;
  503. }
  504. a = 0;
  505. SetConsoleCP(866);
  506. SetConsoleOutputCP(866);
  507. }
  508.  
  509. void dictionary()
  510. {
  511. a = 3;
  512. SetConsoleCP(1251);
  513. SetConsoleOutputCP(1251);
  514. HANDLE hStdout;
  515. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  516. cls(hStdout);
  517. bool exit = true;
  518. while (exit)
  519. {
  520. std::ifstream dictionary_file("dictionary.txt", std::ios_base::in);
  521. std::vector<std::string>v;
  522. std::string S;
  523. if (!dictionary_file.is_open())
  524. write_to_stream("error\n", 7);
  525. while (getline(dictionary_file, S))v.push_back(S);
  526.  
  527. for (unsigned int i = 0; i < v.size(); i++)
  528. {
  529. write_to_stream(v.at(i), 7);
  530. write_to_stream("\n", 7);
  531. }
  532. dictionary_file.close();
  533. write_to_stream("\nif you want to exit, press \"escape\"", 7);
  534. if (_getwch() == 27)
  535. exit = false;
  536. else if (_getwch() != 27)
  537. cls(hStdout);
  538. }
  539. a = 0;
  540. SetConsoleCP(866);
  541. SetConsoleOutputCP(866);
  542. }
  543.  
  544. class math
  545. {
  546. public:
  547. void first_math_menu()
  548. {
  549. int choice_mt = 0, counter_mt = 0;
  550. HANDLE hStdout;
  551. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  552. while (true)
  553. {
  554. switch (choice_mt)
  555. {
  556. case 80:
  557. {
  558. counter_mt++;
  559. if (counter_mt > 4)
  560. counter_mt = 0;
  561. break;
  562. }
  563. case 72:
  564. {
  565. counter_mt--;
  566. if (counter_mt < 0)
  567. counter_mt = 4;
  568. break;
  569. }
  570. case 13:
  571. {
  572. thrid_math_menu(counter_mt);
  573. break;
  574. }
  575. }
  576. cls(hStdout);
  577. second_math_menu(counter_mt);
  578. choice_mt = _getwch();
  579. }
  580. }
  581.  
  582. protected:
  583. void second_math_menu(int choice_mt)
  584. {
  585. table_for_menu();
  586. char variant[5][21] = { "Easy", "Normal", "Hard", "Theory", "Exit" };
  587. write_to_stream("MENU\n",3, { 10, 2 });
  588. for (int i = 0; i < 5; i++)
  589. {
  590. if (i == 0) write_to_stream("",7,{ 8, 3 + i });
  591. if (i == choice_mt)
  592. {
  593. for (int j = 0; j < strlen(variant[i]); j++)
  594. {
  595. write_to_stream(" ", 3, { 8+j, 3 + i });
  596. write_to_stream(variant[i][j], 3, { 8 + j, 3 + i });
  597. }
  598. }
  599. else
  600. {
  601. for (int j = 0; j < strlen(variant[i]); j++)
  602. {
  603. write_to_stream(" ", 7, { 8 + j, 3 + i });
  604. write_to_stream(variant[i][j], 7, { 8 + j, 3 + i });
  605. }
  606. }
  607. write_to_stream("\n", 7);
  608. }
  609. }
  610.  
  611. void thrid_math_menu(int counter_mt)
  612. {
  613. bool exit = true;
  614. while (exit)
  615. {
  616. switch (counter_mt)
  617. {
  618. case 0:
  619. {
  620. HANDLE hStdout;
  621. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  622. cls(hStdout);
  623. easy_math_test();
  624. cls(hStdout);
  625. int choice = 0, counter = 0;
  626. second_math_menu(choice);
  627. choice = _getwch();
  628. cls(hStdout);
  629. first_math_menu();
  630. break;
  631. }
  632. case 1:
  633. {
  634. HANDLE hStdout;
  635. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  636. cls(hStdout);
  637. normal_math_test();
  638. cls(hStdout);
  639. int choice = 0, counter = 0;
  640. second_math_menu(choice);
  641. choice = _getwch();
  642. cls(hStdout);
  643. first_math_menu();
  644. break;
  645. }
  646. case 2:
  647. {
  648. HANDLE hStdout;
  649. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  650. cls(hStdout);
  651. hard_math_test();
  652. cls(hStdout);
  653. int choice = 0, counter = 0;
  654. second_math_menu(choice);
  655. choice = _getwch();
  656. cls(hStdout);
  657. first_math_menu();
  658. break;
  659. }
  660. case 3:
  661. {
  662. HANDLE hStdout;
  663. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  664. cls(hStdout);
  665. theory();
  666. cls(hStdout);
  667. int choice = 0, counter = 0;
  668. second_math_menu(choice);
  669. choice = _getwch();
  670. cls(hStdout);
  671. first_math_menu();
  672. break;
  673. }
  674. case 4:
  675. {
  676. exit = false;
  677. HANDLE hStdout;
  678. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  679. cls(hStdout);
  680. int choice = 0, counter = 0;
  681. first_menu(choice);
  682. choice = _getwch();
  683. cls(hStdout);
  684. thrid_menu(choice, counter);
  685. break;
  686. }
  687. default:
  688. break;
  689. }
  690. }
  691. }
  692. };
  693.  
  694. void easy_math_test()
  695. {
  696. a = 3;
  697. SetConsoleCP(1251);
  698. SetConsoleOutputCP(1251);
  699. HANDLE hStdout;
  700. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  701. cls(hStdout);
  702. std::string S;
  703. std::vector<std::string>v;
  704. std::ifstream math_easy_file("math.txt", std::ios_base::in);
  705. if (!math_easy_file.is_open())
  706. write_to_stream("error\n", 7);
  707. while (getline(math_easy_file, S))v.push_back(S);
  708.  
  709. for (int i = 56; i < 73; i++)
  710. {
  711. if (i == 56 || i == 60 || i == 63 || i == 66 || i == 69 )setcol(12);
  712. else setcol(7);
  713. write_to_stream( v.at(i),7);
  714. write_to_stream("\n", 7);
  715. }
  716. math_easy_file.close();
  717. char arr[5] = { 'Б','В','В','Г','Г'};
  718. char answer;
  719. for (int i = 0; i < 5; i++)
  720. {
  721. write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
  722. write_to_stream(i+1, 7);
  723. std::cin >> answer;
  724. if (answer == arr[i])
  725. {
  726. setcol(12);
  727. write_to_stream("\ncorrect\n", 12);
  728. setcol(7);
  729. }
  730. else
  731. {
  732. setcol(12);
  733. write_to_stream("mistake\n", 12);
  734. setcol(7);
  735. }
  736. }
  737. SetConsoleCP(866);
  738. SetConsoleOutputCP(866);
  739. Sleep(1000);
  740. a = 0;
  741. }
  742.  
  743. void normal_math_test()
  744. {
  745. a = 3;
  746. SetConsoleCP(1251);
  747. SetConsoleOutputCP(1251);
  748. HANDLE hStdout;
  749. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  750. cls(hStdout);
  751. std::string S;
  752. std::vector<std::string>v;
  753. std::ifstream math_normal_file("math.txt", std::ios_base::in);
  754. if (!math_normal_file.is_open())
  755. write_to_stream("error\n", 7);
  756. while (getline(math_normal_file, S))v.push_back(S);
  757.  
  758. for (int i = 73; i < 89; i++)
  759. {
  760. if (i == 73 || i == 76 || i == 80 || i == 83 || i == 86)setcol(12);
  761. else setcol(7);
  762. write_to_stream(v.at(i), 7);
  763. write_to_stream("\n", 7);
  764. }
  765. math_normal_file.close();
  766. char arr[5] = { 'В','Б','Б','А','Б' };
  767. char answer;
  768. for (int i = 0; i < 5; i++)
  769. {
  770. write_to_stream("\nВведіть відповідь (великою буквою) до завдання ", 7);
  771. write_to_stream(i + 1, 7);
  772. std::cin >> answer;
  773. if (answer == arr[i])
  774. {
  775. setcol(12);
  776. write_to_stream("\ncorrect\n", 12);
  777. setcol(7);
  778. }
  779. else
  780. {
  781. setcol(12);
  782. write_to_stream("mistake\n", 12);
  783. setcol(7);
  784. }
  785. }
  786. SetConsoleCP(866);
  787. SetConsoleOutputCP(866);
  788. Sleep(1000);
  789. a = 0;
  790. }
  791.  
  792. void hard_math_test()
  793. {
  794. a = 3;
  795. SetConsoleCP(1251);
  796. SetConsoleOutputCP(1251);
  797. HANDLE hStdout;
  798. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  799. cls(hStdout);
  800. std::string S;
  801. std::vector<std::string>v;
  802. std::ifstream math_normal_file("math.txt", std::ios_base::in);
  803. if (!math_normal_file.is_open())
  804. write_to_stream("error\n", 7);
  805. while (getline(math_normal_file, S))v.push_back(S);
  806.  
  807. for (int i = 89; i < 109; i++)
  808. {
  809. if (i == 89 || i == 93 || i == 96 || i == 101 || i == 105)setcol(12);
  810. else setcol(7);
  811. write_to_stream(v.at(i), 7);
  812. write_to_stream("\n", 7);
  813. }
  814. math_normal_file.close();
  815. char arr[5] = { 'Г','В','Б','Б','В' };
  816. char answer;
  817. for (int i = 0; i < 5; i++)
  818. {
  819. write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
  820. write_to_stream(i + 1, 7);
  821. std::cin >> answer;
  822. if (answer == arr[i])
  823. {
  824. setcol(12);
  825. write_to_stream("\ncorrect\n", 12);
  826. setcol(7);
  827. }
  828. else
  829. {
  830. setcol(12);
  831. write_to_stream("mistake\n", 12);
  832. setcol(7);
  833. }
  834. }
  835. SetConsoleCP(866);
  836. SetConsoleOutputCP(866);
  837. Sleep(1000);
  838. a = 0;
  839. }
  840.  
  841. void theory()
  842. {
  843. SetConsoleCP(1251);
  844. SetConsoleOutputCP(1251);
  845. a = 3;
  846. HANDLE hStdout;
  847. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  848. cls(hStdout);
  849. bool exit = true;
  850. while (exit)
  851. {
  852. std::string S;
  853. std::vector<std::string>v;
  854. std::ifstream math("math.txt", std::ios_base::in);
  855. if (!math.is_open())
  856. write_to_stream("error\n", 7);
  857. while (getline(math, S))v.push_back(S);
  858.  
  859. for (unsigned int i = 0; i < 53; i++)
  860. {
  861. if (i == 0||i==4 || i == 7 || i == 10 || i == 13 || i == 17 || i == 20 || i == 24 || i == 27 || i == 30 || i == 33 || i == 37 || i == 40 || i == 45 || i == 49)setcol(12);
  862. else setcol(7);
  863. write_to_stream(v.at(i), 7);
  864. write_to_stream("\n", 7);
  865. }
  866. math.close();
  867. write_to_stream("\nif you want to exit, press \"escape\"", 7);
  868. if (_getwch() == 27)
  869. exit = false;
  870. else if (_getwch() != 27)
  871. cls(hStdout);
  872. }
  873. a = 0;
  874. SetConsoleCP(866);
  875. SetConsoleOutputCP(866);
  876. }
  877.  
  878. class biology
  879. {
  880. public:
  881. void first_biology_menu()
  882. {
  883. int choice_bio = 0, counter_bio = 0;
  884. HANDLE hStdout;
  885. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  886. while (true)
  887. {
  888. switch (choice_bio)
  889. {
  890. case 80:
  891. {
  892. counter_bio++;
  893. if (counter_bio > 4)
  894. counter_bio = 0;
  895. break;
  896. }
  897. case 72:
  898. {
  899. counter_bio--;
  900. if (counter_bio < 0)
  901. counter_bio = 4;
  902. break;
  903. }
  904. case 13:
  905. {
  906. thrid_biology_menu(counter_bio);
  907. break;
  908. }
  909. }
  910. cls(hStdout);
  911. second_biology_menu(counter_bio);
  912. choice_bio = _getwch();
  913. }
  914. }
  915.  
  916. protected:
  917. void second_biology_menu(int choice_bio)
  918. {
  919. table_for_menu();
  920. char variant[5][10] = { "Easy", "Normal", "Hard", "Theory", "Exit" };
  921. setcol(3);
  922. write_to_stream(" MENU\n",3, { 10, 2 });
  923. for (int i = 0; i < 5; i++)
  924. {
  925. if (i == 0)
  926. write_to_stream("",7,{ 8, 3 + i });
  927. if (i == choice_bio)
  928. {
  929. for (int j = 0; j < strlen(variant[i]); j++)
  930. {
  931. write_to_stream(" ", 3, { 8 + j, 3 + i });
  932. write_to_stream(variant[i][j], 3, { 8 + j, 3 + i });
  933. }
  934. }
  935. else
  936. {
  937. for (int j = 0; j < strlen(variant[i]); j++)
  938. {
  939. write_to_stream(" ", 7, { 8 + j, 3 + i });
  940. write_to_stream(variant[i][j], 7, { 8 + j, 3 + i });
  941. }
  942. }
  943. write_to_stream("\n", 7);
  944. }
  945. }
  946.  
  947. void thrid_biology_menu(int counter_bio)
  948. {
  949. bool exit = true;
  950. while (exit)
  951. {
  952. switch (counter_bio)
  953. {
  954. case 0:
  955. {
  956. HANDLE hStdout;
  957. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  958. cls(hStdout);
  959. easy_bio_test();
  960. cls(hStdout);
  961. int choice = 0, counter = 0;
  962. second_biology_menu(choice);
  963. choice = _getwch();
  964. cls(hStdout);
  965. first_biology_menu();
  966. break;
  967. }
  968. case 1:
  969. {
  970. HANDLE hStdout;
  971. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  972. cls(hStdout);
  973. normal_bio_test();
  974. cls(hStdout);
  975. int choice = 0, counter = 0;
  976. second_biology_menu(choice);
  977. choice = _getwch();
  978. cls(hStdout);
  979. first_biology_menu();
  980. break;
  981. }
  982. case 2:
  983. {
  984. HANDLE hStdout;
  985. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  986. cls(hStdout);
  987. hard_bio_test();
  988. cls(hStdout);
  989. int choice = 0, counter = 0;
  990. second_biology_menu(choice);
  991. choice = _getwch();
  992. cls(hStdout);
  993. first_biology_menu();
  994. break;
  995. }
  996. case 3:
  997. {
  998. HANDLE hStdout;
  999. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1000. cls(hStdout);
  1001. theory_bio();
  1002. write_to_stream("if you wante to exit, press escape",7);
  1003. while (_getwch() != 27)
  1004. {
  1005. Sleep(100);
  1006. }
  1007. cls(hStdout);
  1008. int choice = 0, counter = 0;
  1009. second_biology_menu(choice);
  1010. choice = _getwch();
  1011. cls(hStdout);
  1012. first_biology_menu();
  1013. break;
  1014. }
  1015. case 4:
  1016. {
  1017. exit = false;
  1018. HANDLE hStdout;
  1019. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1020. cls(hStdout);
  1021. int choice = 0, counter = 0;
  1022. first_menu(choice);
  1023. choice = _getwch();
  1024. cls(hStdout);
  1025. thrid_menu(choice, counter);
  1026. break;
  1027. }
  1028. default:
  1029. break;
  1030. }
  1031. }
  1032. }
  1033. };
  1034.  
  1035. void easy_bio_test()
  1036. {
  1037. a = 3;
  1038. SetConsoleCP(1251);
  1039. SetConsoleOutputCP(1251);
  1040. HANDLE hStdout;
  1041. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1042. cls(hStdout);
  1043. std::string S;
  1044. std::vector<std::string>v;
  1045. std::ifstream bio_easy_file("biology.txt", std::ios_base::in);
  1046. if (!bio_easy_file.is_open())
  1047. write_to_stream("error\n", 7);
  1048. while (getline(bio_easy_file, S))v.push_back(S);
  1049.  
  1050. for (int i = 0; i < 26; i++)
  1051. {
  1052. if (i == 0 || i == 6 || i == 11 || i == 16 || i == 21 )setcol(12);
  1053. else setcol(7);
  1054. write_to_stream( v.at(i),7);
  1055. write_to_stream("\n", 7);
  1056. }
  1057. bio_easy_file.close();
  1058. char arr[5] = { 'В','Б','А','А','В'};
  1059. char answer;
  1060. for (int i = 0; i < 5; i++)
  1061. {
  1062. write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
  1063. write_to_stream(i+1, 7);
  1064. std::cin >> answer;
  1065. if (answer == arr[i])
  1066. {
  1067. setcol(12);
  1068. write_to_stream("\ncorrect\n", 12);
  1069. setcol(7);
  1070. }
  1071. else
  1072. {
  1073. setcol(12);
  1074. write_to_stream("mistake\n", 12);
  1075. setcol(7);
  1076. }
  1077. }
  1078. SetConsoleCP(866);
  1079. SetConsoleOutputCP(866);
  1080. Sleep(1000);
  1081. a = 0;
  1082. }
  1083.  
  1084. void normal_bio_test()
  1085. {
  1086. a = 3;
  1087. SetConsoleCP(1251);
  1088. SetConsoleOutputCP(1251);
  1089. HANDLE hStdout;
  1090. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1091. cls(hStdout);
  1092. std::string S;
  1093. std::vector<std::string>v;
  1094. std::ifstream bio_normal_file("biology.txt", std::ios_base::in);
  1095. if (!bio_normal_file.is_open())
  1096. write_to_stream("error\n", 7);
  1097. while (getline(bio_normal_file, S))v.push_back(S);
  1098.  
  1099. for (int i = 26; i < 51; i++)
  1100. {
  1101. if (i == 26 || i == 31 || i == 36 || i == 41 || i == 46)setcol(12);
  1102. else setcol(7);
  1103. write_to_stream(v.at(i), 7);
  1104. write_to_stream("\n", 7);
  1105. }
  1106. bio_normal_file.close();
  1107. char arr[5] = { 'А','Б','В','Б','В' };
  1108. char answer;
  1109. for (int i = 0; i < 5; i++)
  1110. {
  1111. write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
  1112. write_to_stream(i + 1, 7);
  1113. std::cin >> answer;
  1114. if (answer == arr[i])
  1115. {
  1116. setcol(12);
  1117. write_to_stream("\ncorrect\n", 12);
  1118. setcol(7);
  1119. }
  1120. else
  1121. {
  1122. setcol(12);
  1123. write_to_stream("mistake\n", 12);
  1124. setcol(7);
  1125. }
  1126. }
  1127. SetConsoleCP(866);
  1128. SetConsoleOutputCP(866);
  1129. Sleep(1000);
  1130. a = 0;
  1131. }
  1132.  
  1133. void hard_bio_test()
  1134. {
  1135. a = 3;
  1136. SetConsoleCP(1251);
  1137. SetConsoleOutputCP(1251);
  1138. HANDLE hStdout;
  1139. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1140. cls(hStdout);
  1141. std::string S;
  1142. std::vector<std::string>v;
  1143. std::ifstream bio_hard_file("biology.txt", std::ios_base::in);
  1144. if (!bio_hard_file.is_open())
  1145. write_to_stream("error\n", 7);
  1146. while (getline(bio_hard_file, S))v.push_back(S);
  1147.  
  1148. for (int i = 51; i < 76; i++)
  1149. {
  1150. if (i == 51 || i == 56 || i == 61 || i == 67 || i == 71)setcol(12);
  1151. else setcol(7);
  1152. write_to_stream(v.at(i), 7);
  1153. write_to_stream("\n", 7);
  1154. }
  1155. bio_hard_file.close();
  1156. char arr[5] = { 'В','В','Г','А','А' };
  1157. char answer;
  1158. for (int i = 0; i < 5; i++)
  1159. {
  1160. write_to_stream("Введіть відповідь (великою буквою) до завдання ", 7);
  1161. write_to_stream(i + 1, 7);
  1162. std::cin >> answer;
  1163. if (answer == arr[i])
  1164. {
  1165. setcol(12);
  1166. write_to_stream("\ncorrect\n", 12);
  1167. setcol(7);
  1168. }
  1169. else
  1170. {
  1171. setcol(12);
  1172. write_to_stream("mistake\n", 12);
  1173. setcol(7);
  1174. }
  1175. }
  1176. SetConsoleCP(866);
  1177. SetConsoleOutputCP(866);
  1178. Sleep(1000);
  1179. a = 0;
  1180. }
  1181.  
  1182. void theory_bio()
  1183. {
  1184. a = 3;
  1185. SetConsoleCP(1251);
  1186. SetConsoleOutputCP(1251);
  1187. HANDLE hStdout;
  1188. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1189. cls(hStdout);
  1190. std::string S;
  1191. std::vector<std::string>v;
  1192. std::ifstream bio_normal_file("biology.txt", std::ios_base::in);
  1193. if (!bio_normal_file.is_open())
  1194. write_to_stream("error\n", 7);
  1195. while (getline(bio_normal_file, S))v.push_back(S);
  1196.  
  1197. for (int i = 77; i < 94; i++)
  1198. {
  1199. write_to_stream(v.at(i), 7);
  1200. write_to_stream("\n", 7);
  1201. }
  1202. bio_normal_file.close();
  1203. SetConsoleCP(866);
  1204. SetConsoleOutputCP(866);
  1205. Sleep(1000);
  1206. a = 0;
  1207. }
  1208.  
  1209. void first_menu(int choice)
  1210. {
  1211. table_for_menu();
  1212. char variants[5][10] = { "English", "Math", "Biology", "Rules", "Exit" };
  1213. write_to_stream(" MENU\n",3, { 10, 2 });
  1214. for (int i = 0; i < 5; i++)
  1215. {
  1216. if (i == 0) write_to_stream(" " ,7, { 8, 3 + i });
  1217. if (i == choice)
  1218. {
  1219. for (int j = 0; j < strlen(variants[i]); j++)
  1220. {
  1221. write_to_stream("", 7);
  1222. write_to_stream(variants[i][j], 3, { 8+j, 3 + i });
  1223. }
  1224. }
  1225. else
  1226. {
  1227. for (int j = 0; j < strlen(variants[i]); j++)
  1228. {
  1229. write_to_stream("", 7);
  1230. write_to_stream(variants[i][j], 7, { 8+j, 3 + i });
  1231. }
  1232. }
  1233. write_to_stream("\n", 7);
  1234. }
  1235. }
  1236.  
  1237. void second_menu(int counter)
  1238. {
  1239. switch (counter)
  1240. {
  1241. case 0:
  1242. {
  1243. english en;
  1244. en.first_english_menu();
  1245. break;
  1246. }
  1247. case 1:
  1248. {
  1249. math mt;
  1250. mt.first_math_menu();
  1251. break;
  1252. }
  1253. case 2:
  1254. {
  1255. biology bio;
  1256. bio.first_biology_menu();
  1257. break;
  1258. }
  1259. case 3:
  1260. {
  1261. rules();
  1262. break;
  1263. }
  1264. case 4:
  1265. {
  1266. a = 10;
  1267. exit(0);
  1268. break;
  1269. }
  1270. default:
  1271. break;
  1272. }
  1273. }
  1274.  
  1275. void thrid_menu(int choice, int counter)
  1276. {
  1277. HANDLE hStdout;
  1278. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1279. while (true)
  1280. {
  1281. switch (choice)
  1282. {
  1283. case 80:
  1284. {
  1285. counter++;
  1286. if (counter > 4)
  1287. counter = 0;
  1288. break;
  1289. }
  1290. case 72:
  1291. {
  1292. counter--;
  1293. if (counter < 0)
  1294. counter = 4;
  1295. break;
  1296. }
  1297. case 13:
  1298. {
  1299. second_menu(counter);
  1300. break;
  1301. }
  1302. }
  1303. cls(hStdout);
  1304. first_menu(counter);
  1305. choice = _getwch();
  1306. }
  1307. }
  1308.  
  1309. void rules()
  1310. {
  1311. a = 3;
  1312. HANDLE hStdout;
  1313. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1314. cls(hStdout);
  1315. std::string S;
  1316. std::vector<std::string>v;
  1317. std::ifstream rules_file("rules_file.txt", std::ios_base::in);
  1318. if (!rules_file.is_open())
  1319. write_to_stream( "error\n",7);
  1320. while (getline(rules_file, S))v.push_back(S);
  1321.  
  1322. for (unsigned int i = 0; i < v.size(); i++)
  1323. {
  1324. if (i == 0)setcol(12);
  1325. else setcol(3);
  1326. write_to_stream(v.at(i), 3);
  1327. write_to_stream("\n", 7);
  1328. }
  1329. setcol(7);
  1330. rules_file.close();
  1331. write_to_stream("\nif you want to exit, press \"escape\"",7);
  1332. while (_getwch() != 27)Sleep(100);
  1333. a = 0;
  1334. }
  1335.  
  1336. void table_for_menu()
  1337. {
  1338. setcol(7);
  1339. //----------верхня лінія
  1340. write_to_stream((char)201,7, { 1, 0 });
  1341. for (int i = 1; i < 26; i++)
  1342. {
  1343. write_to_stream((char)205,7, { 1 + i, 0 });
  1344. }
  1345. write_to_stream((char)187,7, { 27, 0 });
  1346. //-----------нижня лінія
  1347. write_to_stream((char)200,7, { 1, 9 });
  1348. for (int i = 1; i < 26; i++)
  1349. {
  1350. write_to_stream((char)205,7, { 1 + i, 9 });
  1351. }
  1352. write_to_stream((char)188,7, { 27, 9 });
  1353. // paint_the_flovers();
  1354. //--------права лінія
  1355. for (int i = 1; i < 9; i++)
  1356. {
  1357. write_to_stream((char)186,7, { 27, 0 + i });
  1358. }
  1359. //---------ліва лінія
  1360. for (int i = 1; i < 9; i++)
  1361. {
  1362. write_to_stream((char)186,7, { 1, 0 + i });
  1363. }
  1364. }
  1365.  
  1366. void paint_the_flovers()
  1367. {
  1368. int counter = 0;
  1369. int arr[340] = { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1370. 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, 3,
  1371. 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 1,
  1372. 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1,
  1373. 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3,
  1374. 3, 3, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1,
  1375. 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1376. 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1,
  1377. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
  1378. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  1379. constexpr int x_start = 50;
  1380. constexpr int y_start = 2;
  1381.  
  1382. while (a!=10)
  1383. {
  1384. if (a == 3)
  1385. {
  1386. while (a == 3)
  1387. {
  1388. Sleep(1000);
  1389. }
  1390. }
  1391. int x_offset = 0;
  1392. int y_offset = 0;
  1393. for (int i = 0; i < 340; i++)
  1394. {
  1395. if (i % 20 == 0)
  1396. {
  1397. ++y_offset;
  1398. x_offset = 0;
  1399. }
  1400. switch (arr[i])
  1401. {
  1402. case 1:
  1403. {
  1404. // setpos(50 + i, y + counter);
  1405. // std::cout << " ";
  1406. write_to_stream(" ",7, { x_start + x_offset, y_start + y_offset });
  1407. break;
  1408. }
  1409. case 2:
  1410. {
  1411. // setpos(50 + i, y + counter);
  1412. // std::cout << (char)178 << (char)178;
  1413. write_to_stream((char)178, 15,{ x_start + x_offset, y_start + y_offset });
  1414. break;
  1415. }
  1416. case 3:
  1417. {
  1418. // setpos(50 + i, y + counter);
  1419. if (rand() % 2 + 1 == 1) write_to_stream((char)178, 4,{ x_start + x_offset, y_start + y_offset });
  1420. else if (rand() % 2 + 1 == 2) write_to_stream((char)178,12, { x_start + x_offset, y_start + y_offset });
  1421. else
  1422. write_to_stream((char)178, 13, { x_start + x_offset, y_start + y_offset });
  1423. // std::cout << (char)178 << (char)178;
  1424. break;
  1425. }
  1426. default:
  1427. break;
  1428. }
  1429. ++x_offset;
  1430. }
  1431. }
  1432. }
  1433.  
  1434. #pragma endregion
  1435.  
  1436. struct car
  1437. {
  1438. int x;
  1439. int y;
  1440. }car[100];
  1441.  
  1442. void table_for_game()
  1443. {
  1444. setcol(7);
  1445. //----------верхня лінія
  1446. write_to_stream((char)201, 7, { 1, 0 });
  1447. for (int i = 1; i < 40; i++)
  1448. {
  1449. write_to_stream((char)205, 7, { 1 + i, 0 });
  1450. }
  1451. write_to_stream((char)187, 7, { 27, 0 });
  1452. //-----------нижня лінія
  1453. write_to_stream((char)200, 7, { 1, 9 });
  1454. for (int i = 1; i < 40; i++)
  1455. {
  1456. write_to_stream((char)205, 7, { 1 + i, 9 });
  1457. }
  1458. write_to_stream((char)188, 7, { 27, 9 });
  1459. // paint_the_flovers();
  1460. //--------права лінія
  1461. for (int i = 1; i < 15; i++)
  1462. {
  1463. write_to_stream((char)186, 7, { 27, 0 + i });
  1464. }
  1465. //---------ліва лінія
  1466. for (int i = 1; i < 15; i++)
  1467. {
  1468. write_to_stream((char)186, 7, { 1, 0 + i });
  1469. }
  1470. }
  1471.  
  1472. class asteroids_drow
  1473. {
  1474. public:
  1475. int x, y;
  1476. void New()
  1477. {
  1478. x = rand() % weight;
  1479. y = rand() % weight;
  1480. }
  1481.  
  1482. void drow_aster()
  1483. {
  1484. setcol(rand() % 15);
  1485. std::cout << "#";
  1486. }
  1487. }aster[3];
  1488.  
  1489. void Tick()
  1490. {
  1491. if (dir == 0) car[0].y += 1;
  1492. if (dir == 1) car[0].x -= 1;
  1493. if (dir == 2) car[0].x += 1;
  1494. if (dir == 3) car[0].y -= 1;
  1495.  
  1496. for (int i = 0; i < 10; i++)
  1497. {
  1498. if ((car[0].x == aster[i].x) && (car[0].y == aster[i].y))
  1499. {
  1500. aster[i].New();
  1501. car[i].x = car[i - 1].x;
  1502. car[i].y = car[i - 1].y;
  1503. }
  1504. }
  1505.  
  1506.  
  1507. if (car[0].x > weight)car[0].x = 0;
  1508. if (car[0].y > hight)car[0].y = 0;
  1509. if (car[0].x < 0)car[0].x = weight;
  1510. if (car[0].y < 0)car[0].y = hight;
  1511. }
  1512.  
  1513. void MyKeyboard(int key, int a, int b)
  1514. {
  1515. switch (key)
  1516. {
  1517. case 101: dir = 0; break;
  1518. case 102: dir = 2; break;
  1519. case 100: dir = 1; break;
  1520. case 103: dir = 3; break;
  1521. }
  1522. }
  1523.  
  1524. void game()
  1525. {
  1526. table_for_game();
  1527. for (int i = 0; i < 2; i++)
  1528. {
  1529. aster[i].drow_aster();
  1530. }
  1531. }
  1532.  
  1533. int main()
  1534. {
  1535. setcursor(0);
  1536. //game();
  1537. PlaySound(TEXT("Mendelson.wav"), NULL, SND_FILENAME | SND_ASYNC);
  1538. srand(time(0));
  1539. table_for_menu();
  1540. HANDLE hStdout;
  1541. hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  1542. std::thread th(paint_the_flovers);
  1543. int choice = 0, counter = 0;
  1544. first_menu(choice);
  1545. choice = _getwch();
  1546. cls(hStdout);
  1547. thrid_menu(choice, counter);
  1548. _getwch();
  1549. th.join();
  1550. system("pause>nul");
  1551. return 0;
  1552. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement