Программа "Морской бой"

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

p);">Fild2 -> Picture -> LoadFromFile (net.bmp);

HE = new HandlersOfEvents (Fild1, Fild2);

}

//

UShipBattle.h

//

#ifndef UShipBattleH

#define UShipBattleH

//

">#include

">#include

">#include

">#include

">#include

">#include

">#include

">#include

//

struct Ship

{

bool destroy;

int col_deck;

bool *decks;

TPoint *desp_of_part;

};

class Flot

{

public:

int i, j, n;

bool destroy;

TImage *Im;

Ship ship[10];

Flot (TImage *I)

{

destroy = false;

Im = I;

n = 1;

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

{

if (i < 6) n = 2;

if (i < 3) n = 3;

if (i == 0) n = 4;

ship[i].destroy = false;

ship[i].col_deck = n;

ship[i].decks = new bool[n];

ship[i].desp_of_part = new TPoint[n];

}

}

int GetStatus();

};

class AI

{

public:

TPoint decks_[20];

int col_decks_;

int Generation (Flot *CPU, int col_ship, int col_deck);

};

class Referee: public AI

{

public:

int i, j, target_player, target_CPU;

bool net1 [10] [10], net2 [10] [10], game_over;

Flot *player, *CPU;

Referee()

{

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

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

{

net1 [i] [j] = true;

net2 [i] [j] = true;

}

game_over = false;

target_player = 0;

target_CPU = 0;

col_decks_ = 0;

}

int GoChecking (int x, int y, int n);

int Check (bool net[10] [10], int x, int y);

int GoScaning (int x, int y, int n);

int Scan (Flot *fl, int x, int y);

int Miss (int x, int y, int n);

int EndRaund (int n);

};

class HandlersOfEvents: public Referee

{

public:

bool play;

int col_deck, col_ship, i, j, k;

HandlersOfEvents (TImage *Im1, TImage *Im2)

{

play = false;

col_deck = 4; col_ship = 1;

player = new Flot(Im1);

CPU = new Flot(Im2);

}

int Play (TImage *Im1, TImage *Im2);

int Move();

int Desposition (int x, int y, TMouseButton Button);

int Draw (String key, int x, int y, int n);

int ShootPlayer (int x, int y, int n);

int Shoot (int x, int y);

};

class TForm1: public TForm

{

__published:// IDE-managed Components

TImage *Fild1;

TImage *Fild2;

TPanel *Panel1;

TBitBtn *BitBtn1;

TBitBtn *BitBtn2;

TBitBtn *BitBtn3;

TPanel *Panel2;

void __fastcall Fild2MouseDown (TObject *Sender,

TMouseButton Button, TShiftState Shift, int X, int Y);

void __fastcall BitBtn2Click (TObject *Sender);

void __fastcall Fild1MouseDown (TObject *Sender,

TMouseButton Button, TShiftState Shift, int X, int Y);

void __fastcall BitBtn3Click (TObject *Sender);

private:// User declarations

public:// User declarations

__fastcall TForm1 (TComponent* Owner);

HandlersOfEvents *HE;

};

//

extern PACKAGE TForm1 *Form1;

//

#endif

 

 

Литература

 

1. А.Я.Архангельский. Программирование в C++ Builder 6. - ЗАО Издательство

БИНОМ, Москва, 2005

2. Уильям Топп, Уильям Форд. Структура данных в С++.-ЗАО Издательство

БИНОМ, Москва, 2000

3. В.В.Подбельский. Язык С, С++. Финансы и статистика, Москва, 2003

4. Т.А.Павловская. С/С++. Питер, Санкт-Петербург, 2002