Advertisement
Guest User

Untitled

a guest
May 26th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. char Map[10][10] = {"#########",
  8. "# # !#",
  9. "##### ###",
  10. "## # #",
  11. "## #### #",
  12. "# # #",
  13. "# # #",
  14. "#@# #",
  15. "#########"};
  16. int Gamespeed = 100;
  17. int Level = 0;
  18. bool stopgame = false;
  19.  
  20. int main ()
  21. {
  22.  
  23. while (stopgame == false && Level==0)
  24. {
  25. system("cls");
  26. for (int y= 0;y<10;y++)
  27. {
  28. cout << Map[y] << endl;
  29. }
  30. for (int y= 0;y<10;y++)
  31. {
  32. for (int x = 0; x<10; x++)
  33. {
  34. switch (Map[y][x])
  35. {
  36. case '#':
  37. {
  38. Map[y][x] = 219;
  39. }break;
  40. case '@':
  41. {
  42.  
  43. if (GetAsyncKeyState(VK_UP) !=0)
  44. {
  45. int y2 = (y-1);
  46. switch(Map[y2][x])
  47. {
  48. case ' ' :
  49. {
  50. Map[y][x] = ' ';
  51. y-=1;
  52. Map[y2][x]='@';
  53. } break;
  54. case '!' :
  55. {
  56. Level = 1;
  57. } break;
  58. }
  59. }
  60. if (GetAsyncKeyState(VK_DOWN) !=0)
  61. {
  62. int y2 = (y+1);
  63. switch(Map[y2][x])
  64. {
  65. case ' ' :
  66. {
  67. Map[y][x] = ' ';
  68. y+=1;
  69. Map[y2][x]='@';
  70. } break;
  71. case '!' :
  72. {
  73. Level = 1;
  74. } break;
  75. }
  76. }
  77. if (GetAsyncKeyState(VK_RIGHT) !=0)
  78. {
  79. int x2 = (x+1);
  80. switch(Map[y][x2])
  81. {
  82. case ' ' :
  83. {
  84. Map[y][x] = ' ';
  85. x+=1;
  86. Map[y][x2]='@';
  87. } break;
  88. case '!' :
  89. {
  90. Level = 1;
  91. } break;
  92. }
  93. }
  94. if (GetAsyncKeyState(VK_LEFT) !=0)
  95. {
  96. int x2 = (x-1);
  97. switch(Map[y][x2])
  98. {
  99. case ' ' :
  100. {
  101. Map[y][x] = ' ';
  102. x-=1;
  103. Map[y][x2]='@';
  104. } break;
  105. case '!' :
  106. {
  107. Level = 1;
  108. } break;
  109. }
  110. }
  111.  
  112. }break;
  113. }
  114. }
  115. }
  116. Sleep(Gamespeed);
  117. }
  118. while (stopgame == false && Level==1)
  119. {
  120. system ("cls");
  121. cout << "Level 2 Goes Here" << endl;
  122. system("pause");
  123. return EXIT_SUCCESS;
  124. }
  125. exit (1);
  126. getch ();
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement