bojandam1

main.cpp

May 10th, 2022 (edited)
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. #include <string>
  4. #include <conio.h>
  5. #include "maze.h"
  6. using namespace std;
  7. int PosX=1,PosY=1,valX=3,valY=5;
  8. int Coffies_left=0;
  9. int Lfset=5,Tofset=3,Coockies_needed;
  10. void wipe()
  11. {
  12. for(int i=0;i<40;i++)
  13. cout<<" \n";
  14. }
  15. void Print(){
  16.  
  17. cls();
  18. wipe(); cls();
  19. for(int i=valX-Tofset;i<valX+Tofset;i++)
  20. {
  21. for(int j=valY-Lfset ;j<valY+Lfset;j++)
  22. cout<<maze[i][j];
  23. cout<<endl;
  24. }
  25. cout<<"Coffie : "<<Coffies_left<<"/25"<<endl;
  26. }
  27.  
  28. void UwU()
  29. {
  30. while(1)
  31. {
  32.  
  33. int a=getch();
  34. tolower(a);
  35. if(Coffies_left>=Coockies_needed)maze[13][maze[13].size()-2]=' ';
  36. if(a=='-') break;
  37. maze[PosX][PosY]=' ';
  38. if(a=='w'&&maze[PosX-1][PosY]!='#'&&maze[PosX-1][PosY]!='|')PosX--;
  39. if(a=='s'&&maze[PosX+1][PosY]!='#'&&maze[PosX+1][PosY]!='|')PosX++;
  40. if(a=='a'&&maze[PosX][PosY-1]!='#'&&maze[PosX][PosY-1]!='|')PosY--;
  41. if(a=='d'&&maze[PosX][PosY+1]!='#'&&maze[PosX][PosY+1]!='|')PosY++;
  42.  
  43. if((PosX==M-1||PosY==60)&&Coffies_left>=Coockies_needed){cout<< "You Win UwU\n"; return;}
  44. if(maze[PosX][PosY]=='C')Coffies_left++;
  45. if(PosX-Tofset-1>0&&PosX+Tofset-1<M)valX=PosX;
  46. if(PosY-Lfset-1>0&&PosY+Lfset-2<N1)valY=PosY;
  47.  
  48. maze[PosX][PosY]='U';
  49. Print();
  50.  
  51.  
  52.  
  53. }
  54. }
  55.  
  56. int main()
  57. {
  58. while(1)
  59. {
  60. cout<<"How many cookies needed to win (there are 25 total) 15-Easy 20- Medium 25-Hard\n";
  61. int p=0;string s;cin>>s;bool bad=false;
  62. for(char c:s)
  63. {
  64. if(c<'0'||c>'9'){bad = true; break;}
  65. else p*=10; p+=c-'0';
  66. }
  67. if(p>25||p<0||bad) cout<<"INVALID INPUT try again\n";
  68. else {
  69. Coockies_needed=p;
  70. cls();
  71. wipe();
  72. cls();
  73.  
  74. break;}
  75. }
  76. while(1)
  77. {
  78. cout<<"Enter radius of vision [3,8] default is 5\n";
  79. int p=0;string s;cin>>s;bool bad=false;
  80. for(char c:s)
  81. {
  82. if(c<'0'||c>'9'){bad = true; break;}
  83. else p*=10; p+=c-'0';
  84. }
  85. if(p>8||p<3||bad) cout<<"INVALID INPUT try again\n";
  86. else {
  87. Tofset=p-2;
  88. Lfset=p;
  89. valX=Tofset;
  90. valY=Lfset;
  91. cls();
  92. wipe();
  93. cls();
  94.  
  95. break;}
  96. }
  97.  
  98. Print();
  99. UwU();
  100. cout<<"\n\nPRESS ENTER \n\n";
  101. cin.ignore();
  102. cin.ignore();
  103. return 0;
  104. }
  105.  
Add Comment
Please, Sign In to add comment