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

Автор: Пользователь скрыл имя, 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 Кб (Скачать)

                               }

                           break;

                         }

                         case 75:

                         { if(nap==1)

                         {

                               if (x!=41)

                             {

                               for (e=x;e<x+8;e=e+2){

                              i=(e-40)/2;

                                j=y/2;

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

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

                               }

                               x=x-2;

                               for (e=x;e<x+8;e=e+2)

                           {

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

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

                               }

                               }

                         }

                         else { if (x!=41){

                                      for (e=y;e<y+8;e=e+2)

                                   {

                                           i=(x-40)/2;

                                     j=e/2;

                                       GotoXY(x,e);if((i+j)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}

                                   GotoXY(x,e+1);if((i+j)%2!=0) {SetColor(0,1);printf ("  ");} else{SetColor(0,9);printf ("  ");}

                                 }

                               x=x-2;

                               for (e=y;e<y+8;e=e+2)

                           {

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

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

                               }

                                }

                                }

                               break;

                          }

                         }} 

                         else {switch(code){

                         case 32:

                               {

                               if (nap==1&&y<15||nap==-1&&x<55)

                               {nap=nap*(-1);

                                    if(nap==1)

                         {

                               for (e=y;e<y+8;e=e+2)

                                   {

                                           i=(x-40)/2;

                                     j=e/2;

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

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

                                 }

                              

                               

                               for (e=x;e<x+8;e=e+2)

                           {

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

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

                               }

                               

                         }

                         else {

                                       for (e=x;e<x+8;e=e+2){

                              i=(e-40)/2;

                                j=y/2;

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

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

                               }

                               

                               for (e=y;e<y+8;e=e+2)

                           {

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

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

                               }

                                }

                               }

                                     break;

                               }

                         case 13:{

                                  

                                    if(nap==1)

                         {

                               for (e=x;e<x+8;e=e+2)

                                {i=(e-40)/2;

                                j=y/2;

                                    mypole[i][j]=1;}

                               

                         }

                         else {

                                     

                                for (e=y;e<y+8;e=e+2)

                                {i=(x-40)/2;

                                j=e/2;

                                    mypole[i][j]=1;}

                               } 

                                f=1; break;

                                     }

                         case 27: {f=1;ui=1;break;} 

                   

            }

        

      }}while(f!=1);

                   break; 

  }

        case 2:

              { for(w=0;w<2;w++)

                    if (ui==0)

              {  for (i=0,x=41;i<10,x<61;i++,x=x+2)

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

              {

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

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

              }

                  x=41;y=nap=1;

                 i=j=0;

                 for (e=x;e<x+6;e=e+2)

                   {

                

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

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

                   }

                   do { f=0;

                  int code =getch();

       if (code == 224)

        {

        code = getch();

        switch(code)

                   {

                   {

                   case 72:

                         {

                   if (y!=1)

                           {

                      if (nap==1)

                                {

                                   for (e=x;e<x+6;e=e+2)

                                    {

                                            i=(e-40)/2;

                                      j=y/2;

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

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

                                    }

                                   y=y-2;

                                   for (e=x;e<x+6;e=e+2)

                              {

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

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

                                  }

                                 }

                                else

                                { if (y!=33){

                        for (e=y;e<y+6;e=e+2)

                                   {

                                           i=(x-40)/2;

                                     j=e/2;

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

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

                                 }

                               y=y-2;

                               for (e=y;e<y+6;e=e+2)

                           {

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

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

                               }

                                }

                                }

                               

                              } 

                           break;

                          

                         }

                   case 77:

                         {

                               if (nap==1)

                               {

                               if (x!=55)

                             {

                               for (e=x;e<x+6;e=e+2){

                              i=(e-40)/2;

                                j=y/2;

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

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

                               }

                               x=x+2;

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