Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <Windows.h>
- #define STARTX1 5 //pocetak 1. zida - x kordinata
- #define STARTY1 5 //pocetak 1. zida - y kordinata
- #define STARTX2 45 //pocetak 2. zida - x kordinata
- #define STARTY2 12 //pocetak 2. zida - x kordinata
- int main()
- {
- int i,j,xu,yu,xo=0,yo=0;
- randomize();
- do{
- xu=random(80);
- }while(xu==0||xu==1||((yu==STARTY1&&xu>=STARTX1&&xu<=STARTX1+24)||(yu==STARTY2&&xu>=STARTX2&&xu<=STARTX2+24)));
- do{
- yu=random(24);
- }while(yu==0||yu==1||((yu==STARTY1&&xu>=STARTX1&&xu<=STARTX1+24)||(yu==STARTY2&&xu>=STARTX2&&xu<=STARTX2+24)));
- printf("%c",201);
- for(i=1;i<=78;i++)printf("%c",205);
- printf("%c",187);
- for(j=1;j<=22;j++)
- {
- printf("%c",186);
- for(i=1;i<=78;i++)printf(" ");
- printf("%c",186);
- }
- printf("%c",200);
- for(i=1;i<=78;i++)printf("%c",205);
- printf("%c",188);
- gotoxy(68,25);
- printf("Autor: Mikec"); // ;)
- gotoxy(STARTX1,STARTY1);
- for(i=1;i<=25;i++)printf("%c",196);
- gotoxy(STARTX2,STARTY2);
- for(i=1;i<=25;i++)printf("%c",196);
- while(1){
- gotoxy(xu,yu);
- printf("%c",254);
- gotoxy(xu,yu);
- printf(" ");
- gotoxy(xu+xo,yu+yo);
- xu=wherex();
- yu=wherey();
- printf("%c",254);
- Sleep(70); // BRZINA kretanja
- if(kbhit())
- switch(getch())
- {
- case 'a': xo=-1; yo=0; break;
- case 'd': xo=1; yo=0; break;
- case 'w': xo=0; yo=-1; break;
- case 's': xo=0; yo=1; break;
- default: gotoxy(xu,yu);
- }
- if((yu==STARTY1&&xu>=STARTX1&&xu<=STARTX1+24)||(yu==STARTY2&&xu>=STARTX2&&xu<=STARTX2+24)){clrscr(); printf("\n Udarili ste u horizontalni zid!\n\n"); return 0;}
- if(xu==79&&xo==1)gotoxy(xu,yu),printf(" "),xu=2;
- if(xu==2&&xo==-1)gotoxy(xu,yu),printf(" "),xu=79;
- if(yu==2&&yo==-1)gotoxy(xu,yu),printf(" "),yu=23;
- if(yu==23&&yo==1)gotoxy(xu,yu),printf(" "),yu=2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement