fork download
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <conio.h>
  5. using namespace std;
  6. class Player
  7. {
  8. private:
  9. char scin;
  10. unsigned int X;
  11. unsigned int Y;
  12. public:
  13. void Move(char M)
  14. {
  15. if ((Y > 0) and (M == 'w'))
  16. {
  17. Y = Y + 1;
  18. }
  19. if ((Y < 2) and (M == 's'))
  20. {
  21. Y = Y - 1;
  22. }
  23. if ((X > 0) and (M == 'a'))
  24. {
  25. X = X - 1;
  26. }
  27. if ((X < 0) and (M == 'd'))
  28. {
  29. X = X + 1;
  30. }
  31. }
  32. void Show(char N)
  33. {
  34. system("cls");
  35. char mapp[3][3] = {
  36. { N, N, N },
  37. { N, N, N },
  38. { N, N, N }
  39. };
  40. mapp[X][Y] = '_';
  41. for (int i = 0; i < 3; i++)
  42. {
  43. for (int z = 0; z < 3; z++)
  44. {
  45. cout << mapp[i][z];
  46. }
  47. }
  48. mapp[X][Y] = N;
  49. }
  50. };
  51. int main()
  52. {
  53. Player First;
  54. int key;
  55. key = _getch();
  56. while (true)
  57. {
  58. if (key == 87)
  59. {
  60. First.Move('w');
  61. First.Show(' ');
  62. }
  63. if (key == 83)
  64. {
  65. First.Move('s');
  66. First.Show(' ');
  67. }
  68. if (key == 68)
  69. {
  70. First.Move('d');
  71. First.Show(' ');
  72. }
  73. if (key == 65)
  74. {
  75. First.Move('a');
  76. First.Show(' ');
  77. }
  78. }
  79. system("PAUSE");
  80. return 0;
  81. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
                   ^
compilation terminated.
stdout
Standard output is empty