Advertisement
Guest User

Untitled

a guest
Apr 27th, 2013
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <windows.h>
  4.  
  5.  
  6. void zid (char tab[0][50])
  7. {
  8.     int y,x=18;
  9.     for(y=5;y<15;y++)
  10.         tab[y][x]='|';
  11.     for(y=20;y<30;y++)
  12.         tab[y][x]='|';
  13.     for(y=35;y<45;y++)
  14.         tab[y][x]='|';
  15.  
  16.  
  17.  
  18. }
  19.  
  20. void shot (char tab[0][50], int ss, int y,int st)
  21. {
  22.      ss=ss+4;
  23.      y=y+1;
  24.      tab[y][ss]='-';
  25.  
  26.  
  27.  
  28. }
  29. void ladja (char tab [][50], int x, int y)
  30. {
  31.    int i,j;
  32.    for(i=0;i<50;i++)
  33.    for(j=0;j<50;j++)
  34.    {
  35.        if (i==x&&j==y || i==x+1&&j==y || i==x+2&&j==y ||
  36.                i==x+1&&j==y+1 || i==x+2&&j==y+1 || i==x+3&&j==y+1 ||
  37.            i==x&&j==y+2 || i==x+1&&j==y+2 || i==x+2&&j==y+2 )
  38.            tab[j][i]='*';
  39.    }
  40. }
  41. void napolni (char tab[][50])
  42. {
  43.    int i,j;
  44.    for(i=0;i<50;i++)
  45.    {for(j=0;j<35;j++)
  46.            tab[i][j]=' ';
  47.    }
  48.  
  49. }
  50. void izpisi(char tab[][50])
  51. {
  52.    int i,j;
  53.    for(i=0;i<50;i++)
  54.    {for(j=0;j<50;j++)
  55.            printf("%c",tab[i][j]);
  56.        printf("\n");
  57.    }
  58. }
  59. int main(void)
  60. {
  61.    int x=25, y=25,nes,strel,ss,st=2,check=0,check2=0,y1;
  62.    int i,j;
  63.    char g;
  64.    char ladjice[50][50];
  65.    for(i=1;i<49;i++)  //izpisuje #
  66.    {
  67.        for(j=35;j<50;j++)
  68.            ladjice[i][j]='#';
  69.    }
  70.    for(nes=0;nes<5;)
  71.    {
  72.  
  73.        napolni (ladjice);
  74.        zid (ladjice);
  75.        ladja(ladjice,x,y);
  76.        if(check==1)
  77.        {
  78.            if(check2==1)
  79.            {
  80.            y1=y;
  81.            ss=x;
  82.            strel=x-3;
  83.            check2=0;
  84.            }
  85.            strel++;
  86.            if(strel>42)
  87.                check=0;
  88.            if (strel==11&&
  89.                    (y==4||y==5||y==6||y==7||y==8||y==9||y==10||y==11||y==12||y==13||
  90.                     y==19||y==20||y==21||y==22||y==23||y==24||y==25||y==26||y==27||
  91.                     y==34||y==35||y==36||y==37||y==38||y==39||y==40||y==41||y==42||y==43))
  92.                check=0;
  93.  
  94.  
  95.                       //preverja če se - dotakne #  NE DELA?!?!?!? NUJNO: ladjice[y1+1][ss+4]
  96.             if (ladjice[y1+1][ss+4]=='#')
  97.            {
  98.             check=0;ladjice[y1+1][ss+4]=' ';
  99.             continue;
  100.            }
  101.  
  102.            if(ladjice[y1+1][ss+4]=='|')
  103.                check=0;
  104.  
  105.                shot(ladjice,ss,y1,st);                  //ladjice[ss] [y1]
  106.  
  107.  
  108.            st++;
  109.            ss++;
  110.            printf("WASD/O");
  111.            system("cls");
  112.        }
  113.        izpisi(ladjice);
  114.        if(kbhit())
  115.        {
  116.            g=getch();
  117.            if(g=='d')
  118.            {x++;
  119.                if(x==32)
  120.                    x--;
  121.                if (x==15&&
  122.                        (y==4||y==5||y==6||y==7||y==8||y==9||y==10||y==11||y==12||y==13||
  123.                         y==19||y==20||y==21||y==22||y==23||y==24||y==25||y==26||y==27||y==28||
  124.                         y==34||y==35||y==36||y==37||y==38||y==39||y==40||y==41||y==42||y==43))
  125.                    x--;
  126.                if(x==16&&(y==3||y==14||y==18||y==29||y==33||y==44))
  127.                    x--;
  128.                }
  129.            if(g=='a')
  130.            {x--;
  131.                if(x==-1)
  132.                    x++;
  133.                if (x==18&&
  134.                        (y==3||y==4||y==5||y==6||y==7||y==8||y==9||y==10||y==11||y==12||y==13||y==14||
  135.                         y==18||y==19||y==20||y==21||y==22||y==23||y==24||y==25||y==26||y==27||y==28||y==29||
  136.                         y==33||y==34||y==35||y==36||y==37||y==38||y==39||y==40||y==41||y==42||y==43||y==44))
  137.                    x++;
  138.            }
  139.            if(g=='w')
  140.             {
  141.                y--;
  142.                if(y==-1)
  143.                    y++;
  144.                if((x==18||x==17||x==16)&&(y==14||y==29||y==44))
  145.                    y++;
  146.                if(x==15&&(y==13||y==28||y==43))
  147.                    y++;
  148.  
  149.  
  150.             }
  151.            if(g=='s')
  152.            {
  153.                y++;
  154.                if(y==48)
  155.                y--;
  156.                if((x==18||x==17||x==16)&&(y==3||y==18||y==33))
  157.                    y--;
  158.                if(x==15&&(y==4||y==19||y==34))
  159.                    y--;
  160.  
  161.  
  162.            }
  163.            if(g==32)
  164.            {check=1;
  165.                check2=1;
  166.            }
  167.  
  168.  
  169.            }
  170.  
  171.        system("cls");
  172.    }
  173.  
  174.    return 0;
  175. }
  176.  
  177.  
  178. /*
  179.  *{
  180.                check=0;ladjice[y1+1][ss+4]=' ';continue;
  181.            }
  182.            */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement