Advertisement
rotti321

Dolarel 0.3

Jun 9th, 2021
827
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <conio.h>
  3. using namespace std;
  4. int main()
  5. {
  6.     char ch,a[51][51];
  7.     int n=10,x=1,y=1;
  8.     system("color 02");
  9.     cout<<"w-sus   s-jos    a-stanga    d-dreapta Esc stop"<<endl;
  10.     for(int i=1;i<=n;i++){ ///linia i
  11.         for(int j=1;j<=n;j++){ ///coloana j
  12.             a[i][j]=' ';
  13.         }
  14.     }
  15.     a[2][3]='$';  ///pun la linia 2 si col 3 caracterul $
  16.  
  17.     while(int(ch)!=27){ ///pana la Esc
  18.     a[x][y]='*';
  19.         for(int i=1;i<=n;i++){ ///afisez continutul lui a [tabelul]
  20.             for(int j=1;j<=n;j++){
  21.                 cout<<a[i][j];
  22.                 }
  23.                 cout<<endl;
  24.         }
  25.         ch=_getch();
  26.         a[x][y]=' ';
  27.         if(ch=='w') x--;
  28.         if(ch=='s') x++;
  29.         if(ch=='a') y--;
  30.         if(ch=='d') y++;
  31.         system("cls");
  32.         if(x==2 && y==3) {
  33.             cout<<"Felicitari!!!!";
  34.             break; ///sar din while
  35.         }
  36.         cout<<int(ch)<<" "<<ch<<endl;
  37.     }
  38.     cout<<"Endgame";
  39.     return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement