Guest User

Untitled

a guest
Nov 9th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6.  
  7. void generator();
  8. int x=5;
  9. int y=5;
  10. string hero = "O";
  11. string gameArea[10][10];
  12.  
  13. int main()
  14. {
  15. generator();
  16. while (1){
  17. if(kbhit())
  18. {
  19. char c = getch();
  20. switch(c){
  21. case 'w':
  22. x-=1;
  23. break;
  24. case 's':
  25. x+=1;
  26. break;
  27. case 'd':
  28. y+=1;
  29. break;
  30. case 'a':
  31. y-=1;
  32. break;
  33. default:
  34. continue;
  35. }
  36. cout<< endl;
  37. generator();
  38. }
  39. };
  40. };
  41. void generator(){
  42. for(int rows=0; rows<10; rows++){
  43. for(int cols=0; cols<10;cols++){
  44. if(gameArea[rows][cols]!="+"){
  45. gameArea[rows][cols] = "+";
  46. if(gameArea[rows][cols] == gameArea[x][y]){
  47. gameArea[rows][cols] = hero;
  48. }
  49. }
  50. cout << gameArea[rows][cols];
  51. }
  52. cout << endl;
  53. }
  54. };
Advertisement
Add Comment
Please, Sign In to add comment