Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio2.h>
- //#include <conio.h>
- //Poderia melhorar usando varias coisas, uma delas eh a funcao toupper do CTYPE.H
- #define ENTER 13
- #define UM_SEGUNDO 1000000
- int main()
- {
- char tecla='d';
- int x=40;
- int y=10;
- while (tecla!=13)
- {
- gotoxy(x,y); //posiciona o "cursor" nas coordenadas x,y
- printf("@");
- if (kbhit()) //retorna 1 se a pessoa pressionou algo
- {
- tecla=(char)getch();
- }
- switch (tecla)
- {
- case 'd':x++;break;
- case 'a':x--;break;
- case 'w':y--;break;
- case 's':y++;break;
- }
- gotoxy(1,25); //Fim da tela
- usleep(UM_SEGUNDO/10); //gera um atraso
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement