Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- main() {
- int pole [81][51];
- int i,j;
- for(i=1;i<81;i++)
- for(j=1;j<51;j++)
- pole[i][j]=0;
- for(i=1;i<81;i++){ //stena
- pole[i][1]=1;
- pole[i][49]=1;
- }
- for(j=1;j<50;j++){ //stena
- pole[1][j]=1;
- pole[80][j]=1;
- }
- for (i=1;i<39;i++)
- for (j=16;j<32;j++)
- pole[i][j]=1;
- for (i=52;i<70;i++)
- for (j=1;j<18;j++)
- pole[i][j]=1;
- for (i=48;i<80;i++) //stena
- for (j=42;j<46;j++)
- pole[i][j]=1;
- textmode(C4350);
- textbackground(BLUE);
- textcolor(LIGHTGREEN);
- clrscr();
- _setcursortype(_NOCURSOR);
- for(i=1;i<81;i++) // za steni
- for(j=1;j<50;j++)
- if(pole[i][j]==1){
- gotoxy (i,j);
- cprintf("%c",219);
- }
- int x=5,y=5,pos=1;
- while (1) {
- if (pos==1) {x++;y++;}
- if (pos==2) {x++;y--;}
- if (pos==3) {x--;y--;}
- if (pos==4) {x--;y++;}
- if (pole[x][y+1]==1 && pos==1) pos=2; //posoka pri stena
- if (pole[x+1][y]==1 && pos==2) pos=3;
- if (pole[x][y-1]==1 && pos==3) pos=4;
- if (pole[x][y+1]==1 && pos==4) pos=3;
- if (pole[x-1][y]==1 && pos==3) pos=2;
- if (pole[x][y-1]==1 && pos==2) pos=1;
- if (pole[x-1][y]==1 && pos==4) pos=1;
- if (pole[x+1][y]==1 && pos==1) pos=4;
- if (pole[x-1][y+1]==1 && pos==4) pos=2; //posoka pri agal
- if (pole[x+1][y+1]==1 && pos==1) pos=3;
- if (pole[x+1][y-1]==1 && pos==2) pos=4;
- if (pole[x-1][y-1]==1 && pos==3) pos=1;
- gotoxy(x,y);
- cprintf ("*");
- for (double z=-4000000;z<4000000;z++);
- gotoxy (x,y);
- cprintf (" ");
- } //KRAQ NA WHILE
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement