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

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

                                }

                               break;

                          }

                         }

                         }

                         else {switch(code){

                         case 32:

                               {

                               if (nap==1&&y<19||nap==-1&&x<59)

                               {nap=nap*(-1);

                                    if(nap==1)

                         {

                               for (e=y;e<y+4;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+4;e=e+2)

                           {

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

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

                               }

                               

                         }

                         else {

                                       for (e=x;e<x+4;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+4;e=e+2)

                           {

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

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

                               }

                                }

                               }

                                     break;

                               }

                         case 13:{int pr=f=0;

                                  

                                    if(nap==1)

                         {

                                for (e=x-2;e<=x+4;e=e+2)

                                     for (int a=y-2;a<=y+2;a=a+2)

                                {i=(e-40)/2;

                                j=a/2;

                                if (i<10&&j<10)if (mypole[i][j]==1)

                                pr=1; }

                                if (pr==0)

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

                                     

                                {i=(e-40)/2;

                                j=y/2;

                                    mypole[i][j]=1;f=1;}

                               

                         }

                         else { for (e=y-2;e<=y+4;e=e+2)

                                   for (int a=x-2;a<=x+2;a=a+2)

                                     {i=(a-40)/2;

                                j=e/2;

                                if (i<10&&j<10)if (mypole[i][j]==1)

                                pr=1;}

                                if (pr==0)

                                for (e=y;e<y+4;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 4:

       { for(w=0;w<4;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=1;

                 i=j=0;

                 e=x;

                   {

                

                       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)

                           {

                    

                                   e=x;

                                    {

                                            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;

                                   e=x;

                              {

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

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

                                  }

                           } 

                                 
 

                           break;

                          

                   }

                   case 77:

                         {

                               

                               if (x!=59)

                             {

                               e=x;{

                              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;

                              e=x;

                           {

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

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

                               }

                               }

                          

                               break;

                          }

                   case 80:

                         { 

                               

                   if (y!=19)

                           {

                               e=x;{

                              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;

                              e=x;

                           {

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

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

                               }

                           }

                          

                           break;

                         }

                         case 75:

                         {

                               if (x!=41)

                             {

                               e=x;{

                              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;

                               e=x;

                           {

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

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

                               }

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