Advertisement
lorenzo_valentini

Untitled

Apr 3rd, 2020
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define MAP_SIZE 13
  5.  
  6. int main()
  7. {
  8.     int i=0;
  9.     int j=0;
  10.     int px=(MAP_SIZE-1) /2;
  11.     int py=(MAP_SIZE-1) /2;
  12.    
  13.     char map[MAP_SIZE*MAP_SIZE] = {
  14.         '#','#','#','#','#','#','-','#','#','#','#','#','#',    //da finire
  15.         '#','#','#','#','#','#','-','#','#','#','#','#','#',
  16.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  17.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  18.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  19.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  20.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  21.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  22.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  23.         '#','#','.','.','.','.','.','.','.','.','#','#','#',
  24.         '#','#','#','#','#','#','-','#','#','#','#','#','#',
  25.         '#','#','#','#','#','#','-','#','#','#','#','#','#',
  26.     };
  27.    
  28.     while(true)
  29.     {system("cls");
  30.         for (int i=0; i<MAP_SIZE; i++){
  31.             for(j=0; j<MAP_SIZE; j++){
  32.             if((j==px) && (i==py))
  33.             {
  34.             cout<<"@";
  35.             }
  36.             else{
  37.                 cout<<map[i*MAP_SIZE+j];
  38.             }
  39.         }
  40.         cout<<"\n";
  41.     }
  42.     char input=0;
  43.     cin>>input;
  44.    
  45.     if(input=='w') && il_terreno_รจ_libero
  46.     {
  47.         py=py-1;
  48.     }
  49.     else if(input=='a')
  50.     {
  51.         px=px-1;
  52.     }
  53.     else if(input=='s')
  54.     {
  55.         py=py+1;
  56.     }
  57.     else if(input=='d')
  58.     {
  59.         px=px+1;
  60.     }
  61.     if (py==-1){
  62.         if (input=='w'){
  63.             py=MAP_SIZE-1;
  64.         }
  65.     }
  66.     if(py==10){
  67.         if(input=='s'){
  68.             py=0;
  69.         }
  70.     }
  71.     if(px==-1){
  72.         if(input=='a'){
  73.             px=MAP_SIZE-1;
  74.         }
  75.     }
  76.     if(px==10){
  77.         if(input=='d'){
  78.             px=0;
  79.         }
  80.     }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement