Boneco boneco: mudanças entre as edições
Ir para navegação
Ir para pesquisar
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...') |
imported>Fargoud Sem resumo de edição |
||
| Linha 1: | Linha 1: | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
#include <windows.h> | #include <windows.h> | ||
void gotoXY(int, int); | void gotoXY(int, int); | ||
void desenhaboneco(int, int); | void desenhaboneco(int, int); | ||
int main() | int main() | ||
{ char op; | { char op; | ||
int xatual=40, yatual=24; | int xatual=40, yatual=24; | ||
| Linha 44: | Linha 44: | ||
}while( op!='s' && op!= 'S'); | }while( op!='s' && op!= 'S'); | ||
return 0; | return 0; | ||
} | } | ||
void gotoXY(int x, int y) | void gotoXY(int x, int y) | ||
{//Initialize the coordinates | {//Initialize the coordinates | ||
COORD coord = {x, y}; | COORD coord = {x, y}; | ||
//Set the position | //Set the position | ||
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); | ||
return; | return; | ||
} | } | ||
void desenhaboneco(int x, int y) | void desenhaboneco(int x, int y) | ||
{ system("cls"); | { system("cls"); | ||
gotoXY(x+1,y-3); | gotoXY(x+1,y-3); | ||
printf("O"); | printf("O"); | ||
| Linha 62: | Linha 62: | ||
gotoXY(x,y-1); | gotoXY(x,y-1); | ||
printf("/ \\"); | printf("/ \\"); | ||
} | } | ||
Edição atual tal como às 10h30min de 29 de julho de 2016
#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;
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("/ \\");
}