Guest User

Untitled

a guest
Aug 20th, 2019
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h" //
  2. #include <iostream> //
  3. #include <string> //
  4. #include <ctime> //
  5. #include <conio.h> //
  6.  
  7. using namespace std;
  8.  
  9. bool play = false;
  10. string languages = "en";
  11. int graphics = 1;
  12.  
  13. enum dir:char
  14. {
  15. _left = 'd',
  16. _right = 'a',
  17. _up = 'w',
  18. _down = 's'
  19. };
  20.  
  21. int yPlayer = 8, xPlayer = 0; // player:cordinats
  22.  
  23. void Menu()
  24. {
  25. system("cls");
  26. string menu;
  27. _menu:
  28.  
  29. if (languages == "en")
  30. {
  31. cout << "Play" << endl;
  32. cout << "Setting" << endl;
  33. cout << "Exit" << endl;
  34. cin >> menu;
  35.  
  36. if (menu == "play")
  37. {
  38. play = true;
  39. }
  40. else if (menu == "setting")
  41. {
  42. system("cls");
  43. cout << "languages: " << languages << endl;
  44. cout << "graphics: " << graphics << endl;
  45.  
  46. cout << endl;
  47. cout << "keyboard: " << endl;
  48. cout << "left: " << _left << endl;
  49. cout << "right: " << _right << endl;
  50. cout << "up: " << _up << endl;
  51. cout << "down: " << _down << endl;
  52.  
  53. cin >> menu;
  54.  
  55. if (menu == "lang")
  56. {
  57. cout << "English: en" << endl;
  58. cout << "Russia: ru" << endl;
  59.  
  60. cin >> menu;
  61.  
  62. if (menu == "en")
  63. {
  64. languages = "en";
  65. }
  66. else if (menu == "ru")
  67. {
  68. languages = "ru";
  69. }
  70. goto _menu;
  71. }
  72. else if (menu == "graphics")
  73. {
  74. cout << "1" << endl;
  75. cout << "2" << endl;
  76. cout << "3" << endl;
  77.  
  78. cin >> menu;
  79.  
  80. if (menu == "1") graphics = 1;
  81. else if (menu == "2") graphics = 2;
  82. else if (menu == "3") graphics = 3;
  83. goto _menu;
  84. }
  85. else if (menu == "keyboard")
  86. {
  87. cout << "left: " << endl;
  88. cout << "right: " << endl;
  89. cout << "up: " << endl;
  90.  
  91. cin >> menu;
  92.  
  93. if (menu == "left")
  94. {
  95. cout << "left" << endl;
  96. //cin >> _left;
  97. }
  98. else if (menu == "right")
  99. {
  100. cout << "right" << endl;
  101. //cin >> _right;
  102. }
  103. else if (menu == "up")
  104. {
  105. cout << "up" << endl;
  106. //cin >> _up;
  107. }
  108. cout << "Временно не доступно" << endl;
  109. system("pause");
  110. }
  111. goto _menu;
  112. }
  113. else if (menu == "Exit")
  114. {
  115. return;
  116. }
  117. else
  118. {
  119. goto _menu;
  120. }
  121. }
  122. else if (languages == "ru")
  123. {
  124. setlocale(LC_ALL, "ru");
  125. cout << "Играть" << endl;
  126. cout << "Настройки" << endl;
  127. cout << "Выход" << endl;
  128.  
  129. cin >> menu;
  130.  
  131. if (menu == "play")
  132. {
  133. play = true;
  134. }
  135. else if (menu == "setting")
  136. {
  137. system("cls");
  138. cout << "Языки: " << languages << endl;
  139. cout << "Графика: " << graphics << endl;
  140.  
  141. cout << endl;
  142. cout << "Клавиатура: " << endl;
  143. cout << "лево: " << _left << endl;
  144. cout << "право: " << _right << endl;
  145. cout << "вверх: " << _up << endl;
  146.  
  147. cin >> menu;
  148.  
  149. if (menu == "lang")
  150. {
  151. cout << "Англиский: en" << endl;
  152. cout << "Русский: ru" << endl;
  153.  
  154. cin >> menu;
  155.  
  156. if (menu == "en")
  157. {
  158. languages = "en";
  159. }
  160. else if (menu == "ru")
  161. {
  162. languages = "ru";
  163. }
  164. goto _menu;
  165. }
  166. else if (menu == "graphics")
  167. {
  168. cout << "1" << endl;
  169. cout << "2" << endl;
  170. cout << "3" << endl;
  171.  
  172. cin >> menu;
  173.  
  174. if (menu == "1") graphics = 1;
  175. else if (menu == "2") graphics = 2;
  176. else if (menu == "3") graphics = 3;
  177. goto _menu;
  178. }
  179. else if (menu == "keyboard")
  180. {
  181. cout << "лево: " << endl;
  182. cout << "право: " << endl;
  183. cout << "вверх: " << endl;
  184.  
  185. cin >> menu;
  186.  
  187. if (menu == "left")
  188. {
  189. cout << "лево" << endl;
  190. //cin >> _left;
  191. }
  192. else if (menu == "right")
  193. {
  194. cout << "право" << endl;
  195. //cin >> _right;
  196. }
  197. else if (menu == "up")
  198. {
  199. cout << "вверх" << endl;
  200. //cin >> _up;
  201. }
  202. cout << "Временно не доступно" << endl;
  203. system("pause");
  204. }
  205. goto _menu;
  206. }
  207. else if (menu == "exit")
  208. {
  209. return;
  210. }
  211. else
  212. {
  213. goto _menu;
  214. }
  215. }
  216. }
  217.  
  218. void Game()
  219. {
  220. system("cls");
  221.  
  222. for (int y = -1; y <= 9; y++)
  223. {
  224. for (int x = 0; x <= 167; x++)
  225. {
  226. // y : x
  227. if ( y == 9 && x == x // 167 x 1
  228.  
  229. || y == 7 && x == 5
  230. || y == 7 && x == 6
  231. || y == 7 && x == 7 // 1 x 5
  232. || y == 7 && x == 8
  233. || y == 7 && x == 9
  234.  
  235. || y == 6 && x == 10 // 1 x 1
  236.  
  237. || y == 7 && x == 11
  238. || y == 7 && x == 12
  239. || y == 7 && x == 13 // 1 x 5
  240. || y == 7 && x == 14
  241. || y == 7 && x == 15
  242.  
  243. || y == 8 && x == 15 // 1 x 1
  244.  
  245. || y == 8 && x == 25 // 2 x 1
  246. || y == 7 && x == 25
  247.  
  248. )
  249. {
  250. cout << "+"; // render world
  251.  
  252. if (yPlayer == y && xPlayer == x)
  253. {
  254. if (_kbhit()) // player:keyboard
  255. {
  256. switch (_getch())
  257. {
  258. case _left:
  259. xPlayer -= 1;
  260. break;
  261.  
  262. case _right:
  263. xPlayer += 1;
  264. break;
  265.  
  266. case _up:
  267. yPlayer += 2;
  268. break;
  269.  
  270. case _down:
  271. yPlayer -= 2;
  272. break;
  273. }
  274. }
  275. }
  276. }
  277. else if (yPlayer == y && xPlayer == x) { cout << "#"; } // render player
  278. else { cout << " "; } // render world
  279.  
  280. //cheak: y
  281. if (yPlayer < -2) { yPlayer += 2; }
  282. else if (yPlayer > 9) { yPlayer -= 2; }
  283.  
  284. //cheak: x
  285. else if (xPlayer < 0) { xPlayer += 1; }
  286. else if (xPlayer > 167) { xPlayer -= 1; }
  287. }
  288. }
  289.  
  290. if (_kbhit()) // player:keyboard
  291. {
  292. switch (_getch())
  293. {
  294. case _left:
  295. xPlayer += 1;
  296. break;
  297.  
  298. case _right:
  299. xPlayer -= 1;
  300. break;
  301.  
  302. case _up:
  303. yPlayer -= 2;
  304. break;
  305.  
  306. case _down:
  307. yPlayer += 2;
  308. break;
  309. }
  310. }
  311. }
  312.  
  313. int main()
  314. {
  315. //Menu();
  316. while (play) Game();
  317. }
RAW Paste Data