Advertisement
lorenzo_valentini

Untitled

Mar 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 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.     {system("cls");
  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 (py==-1){
  44.         if (input=='w'){
  45.             py=9;
  46.         }
  47.     }
  48.     if(py==10){
  49.         if(input=='s'){
  50.             py=0;
  51.         }
  52.     }
  53.     if(px==-1){
  54.         if(input=='a'){
  55.             px=9;
  56.         }
  57.     }
  58.     if(px==10){
  59.         if(input=='d'){
  60.             px=0;
  61.         }
  62.     }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement