Разработка программного обеспечения для компьютерной игры "Морской Бой"

Автор: Пользователь скрыл имя, 12 Января 2012 в 22:27, курсовая работа

Краткое описание

Данная программа представляет собой полностью оеализованную компьютерную игру «Морской бой» в режиме компьютер-игрок. Правила игры простые, интерфейс интуитивно понятен. Игра прекрасно подходит для хорошего время провождения, развивает различный умственные качества. Достоинтсва программы заключаются в том что имеется два режима расстоновки кораблей для пользователя – «ручной» и автоматический. Так же компьютер обладает собственным интеллектом, так что игра покажется пользователю интересной и увлекательной.

Оглавление

Введение 4
1 Постановка задачи 5
2 Решение задачи 6
3 Описание программного обеспечения 7
3.1 Программная реализация 7
3.2 Общие сведения 7
3.2.1 Список файлов 7
3.2.2 Технические требования 7
3.3Алгоритм 7
3.4 Состав программы 8
Заключение 10
Список используемых источников 11

Файлы: 1 файл

Отчёт (2).doc

— 238.50 Кб (Скачать)

                                    GotoXY(e,y+1);if(pole[i][j]==3){SetColor(0,11);printf ("  ");}else {if (pole[i][j]==2){SetColor(0,12);printf ("  ");}else {if((i+j)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}}}

                               }

                               y=y+2;

                              e=x;

                           {

                               GotoXY(e,y); SetColor(0,14);printf ("  ");

                               GotoXY(e,y+1); SetColor(0,14);printf ("  ");

                               }

                           }

                          

                           break;

                         }

                         case 75:

                         {

                               if (x!=1)

                             {

                               e=x;{

                              i=e/2;

                                j=y/2;

                                    GotoXY(e,y);if(pole[i][j]==3){SetColor(0,11);printf ("  ");}else {if (pole[i][j]==2){SetColor(0,12);printf ("  ");}else {if((i+j)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}}}

                                    GotoXY(e,y+1);if(pole[i][j]==3){SetColor(0,11);printf ("  ");}else {if (pole[i][j]==2){SetColor(0,12);printf ("  ");}else {if((i+j)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}}}

                               }

                               x=x-2;

                               e=x;

                           {

                               GotoXY(e,y); SetColor(0,14);printf ("  ");

                               GotoXY(e,y+1); SetColor(0,14);printf ("  "); 

                               }

                               }

                          

                               break;

                   }

                 }}

         else {switch(code) {

                         case 13:{

                                int pr=f=0;

                                

                                pop=0;

                                e=x;

                                     int a=y;

                                {i=e/2;

                                j=a/2;

                                if (i<10&&j<10)if (pole[i][j]==2||pole[i][j]==3)

                                pr=1; }

                                if (pr==0)

                                {e=x;

                                     

                                i=e/2;

                                j=y/2;

                                    if (pole[i][j]==0)

                                    {pole[i][j]=3;f=1;GotoXY(28,16);SetColor(15,0);printf (Rus("Ieii!"));}

                                    else {pole[i][j]=2; printf ("\x07");GotoXY(27,16);SetColor(15,0);printf (Rus("Iiiae!"));pop=1;udar++;}}

                                 break;

                                     }

                         case 27: { f=1;

      GotoXY(24,14); SetColor(15,0);printf (Rus("    Aueoe?    "));

      GotoXY(24,16);SetColor(15,0);printf ("[");SetColor(0,2); printf (Rus("aa"));SetColor(15,0);printf ("]  ");

      GotoXY(31,16);SetColor(15,0);printf ("  ["); printf (Rus("iao"));SetColor(15,0);printf ("]");

      do {k=0;vih=0;

      int code =getch();

    if (code == 224)

      {

        code = getch();

            switch(code)

            {

            case 75: {f=f*(-1);

                           if (f==1){GotoXY(24,16);SetColor(15,0);printf ("[");SetColor(0,2); printf (Rus("aa"));SetColor(15,0);printf ("]  ");

                                 GotoXY(31,16);SetColor(15,0);printf ("  ["); printf (Rus("iao"));SetColor(15,0);printf ("]");}

                               else{ GotoXY(24,16);SetColor(15,0);printf ("["); printf (Rus("aa"));printf ("]  ");

                                     GotoXY(31,16);SetColor(15,0);printf ("  [");SetColor(0,2);printf (Rus("iao"));SetColor(15,0);printf ("]");}

                               break;}

                         

            case 77: {f=f*(-1);

                           if (f==1){GotoXY(24,16);SetColor(15,0);printf ("[");SetColor(0,2); printf (Rus("aa"));SetColor(15,0);printf ("]  ");

                                         GotoXY(31,16);SetColor(15,0);printf ("  ["); printf (Rus("iao"));SetColor(15,0);printf ("]");}

                               else{ GotoXY(24,16);SetColor(15,0);printf ("["); printf (Rus("aa"));printf ("]  ");

                                     GotoXY(31,16);SetColor(15,0);printf ("  [");SetColor(0,2);printf (Rus("iao"));SetColor(15,0);printf ("]");}

                               break;}

                         

            }

      } 

      else {switch(code)

      {

                         case 13:{GotoXY(24,14); SetColor(0,0);printf (Rus("              "));

      GotoXY(24,16);printf ("              ");

      if(f==1) k=1;  vih=1; break;}

      } 

       

      } while (vih==0);

      break;} 

       } 

                                      int mas[20][2], flag,sh=0, a,b;

for(i=0;i<10;i++)

              for(j=0;j<10;j++)

              {

                    if(pole[i][j]==1)

                                    {

                                          if(i>0)if(pole[i-1][j]==2){mas[sh][0]=i-1;mas[sh][1]=j; sh++;

                                          if(i>1)if(pole[i-2][j]==2){mas[sh][0]=i-2;mas[sh][1]=j;sh++;

                                          if(i>2)if(pole[i-3][j]==2){mas[sh][0]=i-3;mas[sh][1]=j; sh++;}}}

                           

                                          if(i<9)if(pole[i+1][j]==2){mas[sh][0]=i+1;mas[sh][1]=j; sh++;

                                          if(i<8)if(pole[i+2][j]==2){mas[sh][0]=i+2;mas[sh][1]=j;sh++;

                                          if(i<7)if(pole[i+3][j]==2){mas[sh][0]=i+3;mas[sh][1]=j; sh++;}}} 

                                          if(j>0)if(pole[i][j-1]==2){mas[sh][0]=i;mas[sh][1]=j-1; sh++;

                                          if(j>1)if(pole[i][j-2]==2){mas[sh][0]=i;mas[sh][1]=j-2;sh++;

                                          if(j>2)if(pole[i][j-3]==2){mas[sh][0]=i;mas[sh][1]=j-3; sh++;}}} 

                                          if(j<9)if(pole[i][j+1]==2){mas[sh][0]=i;mas[sh][1]=j+1; sh++;

                                          if(i<8)if(pole[i][j+2]==2){mas[sh][0]=i;mas[sh][1]=j+2;sh++;

                                          if(i<7)if(pole[i][j+3]==2){mas[sh][0]=i;mas[sh][1]=j+3; sh++;}}}

                              }

              }

for(i=0;i<10;i++)

              for(j=0;j<10;j++)

              {b=0;

                 if(pole[i][j]==2)

                   {for(a=0;a<sh;a++)

                               if(i==mas[a][0]&&j==mas[a][1])

                                     b=1;

                   if(b==0)

                         {

                                          if(i>0){if(pole[i-1][j]==0){pole[i-1][j]=3;}}

                                          if(i<9){if(pole[i+1][j]==0){pole[i+1][j]=3;}}

                                          if(j>0){if(pole[i][j-1]==0){pole[i][j-1]=3;}}

                                          if(j<9){if(pole[i][j+1]==0){pole[i][j+1]=3;}}

                                          if(i>0&&j>0){if(pole[i-1][j-1]==0){pole[i-1][j-1]=3;}}

                                          if(i>0&&j<9){if(pole[i-1][j+1]==0){pole[i-1][j+1]=3;}}

                                          if(i<9&&j<9){if(pole[i+1][j+1]==0){pole[i+1][j+1]=3;}}

                                          if(i<9&&j>0){if(pole[i+1][j-1]==0){pole[i+1][j-1]=3;}}

                                    }

                   } 

              }

iper=x;jper=y;

GotoXY(e,y); SetColor(0,14);printf ("  ");

                               GotoXY(e,y+1); SetColor(0,14);printf ("  "); 

for (i=0,x=1;i<10,x<21;i++,x=x+2)

            for (j=0,y=1;j<10,y<21;j++,y=y+2) 

              {

                    GotoXY(x,y);switch(pole[i][j]){

                          case 0:if((j+i)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}break;

                          case 1:if((j+i)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}break;

                          case 2:SetColor(0,12);printf ("  ");break;

                  case 3: SetColor(0,11);printf ("  ");break;

                          }

                    GotoXY(x,y+1);switch(pole[i][j]){

                          case 0:if((j+i)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}break;

                          case 1:if((j+i)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}break;

                          case 2:SetColor(0,12);printf ("  ");break;

                  case 3: SetColor(0,11);printf ("  ");break;}

              }

        x=iper;y=jper; 

                                      udar=0;

            for(i=0;i<10;i++)

              for(j=0;j<10;j++)

                    if(pole[i][j]==2||pole[i][j]==2)

                          udar++;

      end=0; if(udar==20)

        {f=1;pop=0;} 

             if (k==1)

  { udar=-1; f=1;}    } 

  GotoXY(20,20);

      printf("%d",udar); }while((f!=1||pop!=0)); 

    

return udar;

} 

int main()

{

 

   int pole[10][10],mypole[10][10],x,y,ui,ud[2],hod[1];

   int i,j,m,k;

   keybd_event(VK_MENU,0x38,0,0); //press ALT

   keybd_event(VK_RETURN,0x1c,0,0); //press ENTER

   keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0); //release ENTER

   keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0); //release ALT

   do{m=menu();ui=0;if (m==1)

   {SetColor(0,0);

    system ("cls");

    int f=1;

      GotoXY(30,10); SetColor(15,0);printf (Rus("?annoaaeou ei?aaee"));

      GotoXY(23,13);SetColor(15,0);printf ("[");SetColor(0,2); printf (Rus("aaoiiaoe?anee"));SetColor(15,0);printf ("]");

      GotoXY(43,13);SetColor(15,0);printf ("["); printf (Rus("a?o?io?"));SetColor(15,0);printf ("]");

      do {k=0;

      int code =getch();

Информация о работе Разработка программного обеспечения для компьютерной игры "Морской Бой"