tify"> {i; (i=0; i lt; amountDeck; i ++) [] location [i]; [] location;
}
Файл dectroyer.h
# ifndef DESTROYER_H
# define DESTROYER_H
# include ships.h
Destroyer: public Ships
{: ();
~ Destroyer ();
};
# endif//DESTROYER_H
Файл dectroyer.cpp
# include destroyer.h
:: Destroyer ()
{i;=2;
=new int * [amountDeck]; (i=0; i lt; amountDeck; i ++) [i]=new int [2];
}
:: ~ Destroyer ()
{i; (i=0; i lt; amountDeck; i ++) [] location [i]; [] location;
}
Файл enemyfield.h
# ifndef ENEMYFIELD_H
# define ENEMYFIELD_H
# include field.h
EnemyField: public Field
{_ OBJECT: ();
~ EnemyField ();
calcPos (); buildShips (int size); mousePressEvent (QMouseEvent * event);
: EFSignal ();
slots: autoBuild ();
};
# endif//ENEMYFIELD_H
Файл enemyfield.hcpp
# include enemyfield.h
:: EnemyField ()
{ gt; setScene ( amp; scene);
} EnemyField :: calcPos ()
{= (rand ()% 9 + 0) +1;=(rand ()% 9 + 0) +1;
}
EnemyField :: mousePressEvent (QMouseEvent * event)
{x, y;=event- gt; pos (). x () - 30;=event- gt; pos (). y () - 20; (event- gt; button ( ) == Qt :: LeftButton)
{(x gt;=30 amp; amp; x lt;=330 amp; amp; y gt;=30 amp; amp; y lt;=330)
{= y/30;=x/30; startFight ();
}
}
}
EnemyField :: autoBuild ()
{l;
=4; (size); (l=0; l lt; 2; l ++)
{= 0;=3; (size);
}
(l=0; l lt; 3; l ++)
{= 0;=2; (size);
}
(l=0; l lt; 4; l ++)
{= 0;=1; (size);
}=10;
}
EnemyField :: buildShips (int size)
{(amount!=1)
{(); (flag, t, size);
}
} :: ~ EnemyField ()
{
}
Файл field.h
# ifndef FIELD_H
# define FIELD_H
# include lt; QtGui gt;
# include lt; QApplication gt;
# include lt; QSettings gt;
# include battleship.h
# include cruiser.h
# include destroyer.h
# include boat.h
Field: public QGraphicsView
{_ OBJECT: ();
~ Field ();
scene; paintField (QColor Bcolor, QColor Lcolor);
player [10] [10]; iShip, jShip; size; amount; flag; t; move; thI, twI, oI; K; f; lhit, h; M [4] [2 ]; sizeField, sizeDeck; lColor, bColor, deckColor, hitColor;
fourDeck; threeDeck [2]; twoDeck [3]; oneDeck [4];
void calcPos (int x, int y);// зіставляє позицію натискання ЛФМ з player [] [] loadField (QColor lColor, QColor bColor, QColor deckColor, QColor hitColor);// вивантажує player [] [] на ігрове полеsave (QByteArray amp; array); saveShips (QByteArray amp; array); supSaveShips (QByteArray amp; array, int s, int ** m); matrix ();
: completed (); startFight (); endFight (); miss (); hit ();
slots: fire ();
: selectShip (int amp; flag, int amp; t, int amp; size);// виділяє палуби для остаточної прорісовкіpaintShip (int size, QColor lColor, QColor deckColor);// заповнює player [] [] checkPosition ();// перевіряє, чи можна поставити палубу
void wound (int i, int j, QColor lColor, QColor hitColor);// обробляє попадання в корабльpas...