Boneco boneco

De IFSC
Revisão de 10h10min de 29 de julho de 2016 por imported>Fargoud (Criou página com '#include <stdio.h> #include <stdlib.h> #include <windows.h> void gotoXY(int, int); void desenhaboneco(int, int); int main() { char op; int xatual=40, yatual=24; pri...')
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
Ir para navegação Ir para pesquisar
  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <windows.h>

void gotoXY(int, int); void desenhaboneco(int, int);

int main() { char op;

  int xatual=40, yatual=24;
   printf("**** BONECO ****");
   desenhaboneco(xatual, yatual);
   do
   {   gotoXY(5,1);
       printf("\nDigite \'e\', para andar para a ESQUERDA, \'d\', para andar para a DIREITA e \'s\', para sair \n:> ");
      op = getche();
      switch(op)
     {
       case 'e':
       case 'E': xatual--;
                 if(xatual<=0) xatual = 80;
                 desenhaboneco(xatual, yatual);
               break;
       case 'd':
       case 'D': xatual++;
               if(xatual>=80) xatual = 0;
                 desenhaboneco(xatual, yatual);
               break;
       case 'c':
       case 'C': yatual--;
                 if(yatual<=0) yatual = 24;
                 desenhaboneco(xatual, yatual);
               break;
       case 'b':
       case 'B': yatual++;
                 if(yatual>=24) yatual = 0;
                 desenhaboneco(xatual, yatual);
               break;
     }
   }while( op!='s'  && op!= 'S');
      return 0;

}

void gotoXY(int x, int y) {//Initialize the coordinates

   COORD coord = {x, y};
   //Set the position
   SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
   return;

}

void desenhaboneco(int x, int y) { system("cls");

     gotoXY(x+1,y-3);
     printf("O");
     gotoXY(x,y-2);
     printf("/|\\");
     gotoXY(x,y-1);
      printf("/ \\");

}