Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ruch(Snake *g, Snake *h){
- while (_kbhit()){
- switch (_getch()){
- case lewo:
- if (g->y>1){
- while (1){
- putcharXY(g->x, g->y, 32);
- g->y--;
- putcharXY(g->x, g->y, 176);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- case prawo:
- if (g->y<width - 2){
- while (1){
- putcharXY(g->x, g->y, 32);
- g->y++;
- putcharXY(g->x, g->y, 176);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- case gora:
- if (g->x>1){
- while (1){
- putcharXY(g->x, g->y, 32);
- g->x--;
- putcharXY(g->x, g->y, 176);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- case dol:
- if (g->x<height - 2){
- while (1){
- putcharXY(g->x, g->y, 32);
- g->x++;
- putcharXY(g->x, g->y, 176);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- case 'a':
- if (h->y>1){
- while (1){
- putcharXY(h->x, h->y, 32);
- h->y--;
- putcharXY(h->x, h->y, 178);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- case 'd':
- if (h->y<width - 2){
- while (1){
- putcharXY(h->x, h->y, 32);
- h->y++;
- putcharXY(h->x, h->y, 178);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- case 'w':
- if (h->x>1){
- while (1){
- putcharXY(h->x, h->y, 32);
- h->x--;
- putcharXY(h->x, h->y, 178);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- case 's':
- if (h->x<height - 2){
- while (1){
- putcharXY(h->x, h->y, 32);
- h->x++;
- putcharXY(h->x, h->y, 178);
- Sleep(500);
- if (_getch){
- ruch(g, h);
- }
- }
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement