Advertisement
lorenzo_valentini

Untitled

Mar 28th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int i=0;
  6.     int j=0;
  7.     int px=4;
  8.     int py=4;
  9.    
  10.     while(true)
  11.     {
  12.         for (int i=0; i<10; i++){
  13.             for(j=0; j<10; j++){
  14.             if((j==px) && (i==py))
  15.             {
  16.             cout<<"@";
  17.             }
  18.             else{
  19.                 cout<<".";
  20.             }
  21.         }
  22.         cout<<"\n";
  23.     }
  24.     char input=0;
  25.     cin>>input;
  26.    
  27.     if(input=='w')
  28.     {
  29.         py=py-1;
  30.     }
  31.     else if(input=='a')
  32.     {
  33.         px=px-1;
  34.     }
  35.     else if(input=='s')
  36.     {
  37.         py=py+1;
  38.     }
  39.     else if(input=='d')
  40.     {
  41.         px=px+1;
  42.     }
  43.     if ((px==0) && (py==0)){
  44.         if (input=='w'){
  45.             px=10;
  46.             py=10;
  47.         }
  48.     }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement