Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <windows.h>
- void zid (char tab[0][50])
- {
- int y,x=18;
- for(y=5;y<15;y++)
- tab[y][x]='|';
- for(y=20;y<30;y++)
- tab[y][x]='|';
- for(y=35;y<45;y++)
- tab[y][x]='|';
- }
- void shot (char tab[0][50], int ss, int y,int st)
- {
- ss=ss+4;
- y=y+1;
- tab[y][ss]='-';
- }
- void ladja (char tab [][50], int x, int y)
- {
- int i,j;
- for(i=0;i<50;i++)
- for(j=0;j<50;j++)
- {
- if (i==x&&j==y || i==x+1&&j==y || i==x+2&&j==y ||
- i==x+1&&j==y+1 || i==x+2&&j==y+1 || i==x+3&&j==y+1 ||
- i==x&&j==y+2 || i==x+1&&j==y+2 || i==x+2&&j==y+2 )
- tab[j][i]='*';
- }
- }
- void napolni (char tab[][50])
- {
- int i,j;
- for(i=0;i<50;i++)
- {for(j=0;j<35;j++)
- tab[i][j]=' ';
- }
- }
- void izpisi(char tab[][50])
- {
- int i,j;
- for(i=0;i<50;i++)
- {for(j=0;j<50;j++)
- printf("%c",tab[i][j]);
- printf("\n");
- }
- }
- int main(void)
- {
- int x=25, y=25,nes,strel,ss,st=2,check=0,check2=0,y1;
- int i,j;
- char g;
- char ladjice[50][50];
- for(i=1;i<49;i++) //izpisuje #
- {
- for(j=35;j<50;j++)
- ladjice[i][j]='#';
- }
- for(nes=0;nes<5;)
- {
- napolni (ladjice);
- zid (ladjice);
- ladja(ladjice,x,y);
- if(check==1)
- {
- if(check2==1)
- {
- y1=y;
- ss=x;
- strel=x-3;
- check2=0;
- }
- strel++;
- if(strel>42)
- check=0;
- if (strel==11&&
- (y==4||y==5||y==6||y==7||y==8||y==9||y==10||y==11||y==12||y==13||
- y==19||y==20||y==21||y==22||y==23||y==24||y==25||y==26||y==27||
- y==34||y==35||y==36||y==37||y==38||y==39||y==40||y==41||y==42||y==43))
- check=0;
- //preverja če se - dotakne # NE DELA?!?!?!? NUJNO: ladjice[y1+1][ss+4]
- if (ladjice[y1+1][ss+4]=='#')
- {
- check=0;ladjice[y1+1][ss+4]=' ';
- continue;
- }
- if(ladjice[y1+1][ss+4]=='|')
- check=0;
- shot(ladjice,ss,y1,st); //ladjice[ss] [y1]
- st++;
- ss++;
- printf("WASD/O");
- system("cls");
- }
- izpisi(ladjice);
- if(kbhit())
- {
- g=getch();
- if(g=='d')
- {x++;
- if(x==32)
- x--;
- if (x==15&&
- (y==4||y==5||y==6||y==7||y==8||y==9||y==10||y==11||y==12||y==13||
- y==19||y==20||y==21||y==22||y==23||y==24||y==25||y==26||y==27||y==28||
- y==34||y==35||y==36||y==37||y==38||y==39||y==40||y==41||y==42||y==43))
- x--;
- if(x==16&&(y==3||y==14||y==18||y==29||y==33||y==44))
- x--;
- }
- if(g=='a')
- {x--;
- if(x==-1)
- x++;
- if (x==18&&
- (y==3||y==4||y==5||y==6||y==7||y==8||y==9||y==10||y==11||y==12||y==13||y==14||
- y==18||y==19||y==20||y==21||y==22||y==23||y==24||y==25||y==26||y==27||y==28||y==29||
- y==33||y==34||y==35||y==36||y==37||y==38||y==39||y==40||y==41||y==42||y==43||y==44))
- x++;
- }
- if(g=='w')
- {
- y--;
- if(y==-1)
- y++;
- if((x==18||x==17||x==16)&&(y==14||y==29||y==44))
- y++;
- if(x==15&&(y==13||y==28||y==43))
- y++;
- }
- if(g=='s')
- {
- y++;
- if(y==48)
- y--;
- if((x==18||x==17||x==16)&&(y==3||y==18||y==33))
- y--;
- if(x==15&&(y==4||y==19||y==34))
- y--;
- }
- if(g==32)
- {check=1;
- check2=1;
- }
- }
- system("cls");
- }
- return 0;
- }
- /*
- *{
- check=0;ladjice[y1+1][ss+4]=' ';continue;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement