Skip to content

Commit

Permalink
Ajout du nombre de bateaux
Browse files Browse the repository at this point in the history
  • Loading branch information
simonh88 committed Nov 17, 2015
1 parent 530a09d commit 1949b43
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ std::string Board::sBateaux(std::vector<int> bateaux){
/*Affichage du nombre de bateaux
* pour debug
*/
void Board::printNbBateaux()
std::string Board::printNbBateaux()
{
cout << "Nombre de bateaux : " << nbBoat << endl;
// ce sera actualiser a chaque comptage de bateaux.
return intToString(nbBoat);
}
/* Comptage du nombre de bateaux d'un board
* Return un tableau contenant les tailles des bateaux(vector)
Expand Down
2 changes: 1 addition & 1 deletion Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Board : public sf::Drawable, public sf::Transformable
int getBoard(int x, int y);
std::vector<std::vector<int> > getCheckerboard();
std::vector<int> nbBateaux(std::vector<std::vector<int> > checkerBoard);
void printNbBateaux();
std::string printNbBateaux();
void printBateaux(std::vector<int> bateaux);
std::string sBateaux(std::vector<int> bateaux);
std::string intToString (int a);
Expand Down
6 changes: 3 additions & 3 deletions Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ void Display::tailleComposants(sf:: RenderWindow *window)
}
/*Affichage de nombreuses stats */
void Display::blitStatistics(sf::RenderWindow *window, const std::string& turn,const std::string& sizeBoatMoi,
const std::string& sizeBoatIa)
const std::string& sizeBoatIa, const std::string& nbBoatMoi, const std::string& nbBoatIa)
{
/* COMPUTER */
window->draw(setStaticText("Boat alive : " , 23, sf::Vector2u(410,400), false, false));
window->draw(setStaticText("Boat alive : " + nbBoatIa, 23, sf::Vector2u(410,400), false, false));
window->draw(setStaticText("Size of boat alive : " + sizeBoatIa, 23, sf::Vector2u(410,425), false, false));
window->draw(setStaticText("Number of parts alive : ", 23, sf::Vector2u(410,450), false, false));
window->draw(setStaticText("Number of turns : " + turn, 23, sf::Vector2u(410,480), false, false));
window->draw(setStaticText("Number of water hit : ", 23, sf::Vector2u(410,510), false, false));
window->draw(setStaticText("Number of boat hit : ", 23, sf::Vector2u(410,540), false, false));
window->draw(setStaticText("Total hit : ", 23, sf::Vector2u(410,568), false, false));
/* PLAYER */
window->draw(setStaticText("Boat alive : " , 23, sf::Vector2u(10,400), false, false));
window->draw(setStaticText("Boat alive : " + nbBoatMoi, 23, sf::Vector2u(10,400), false, false));
window->draw(setStaticText("Size of boat alive : " + sizeBoatMoi, 23, sf::Vector2u(10,425), false, false));
window->draw(setStaticText("Number of parts alive : ", 23, sf::Vector2u(10,450), false, false));
window->draw(setStaticText("Number of turns : " + turn, 23, sf::Vector2u(10,480), false, false));
Expand Down
3 changes: 2 additions & 1 deletion Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Display
bool flashingText(sf::RenderWindow *window);
void opacitychange();
bool textPlacementLoop(sf::RenderWindow *window);
void blitStatistics(sf::RenderWindow *window, const std::string& turn, const std::string& sizeBoatMoi, const std::string& sizeBoatIa);
void blitStatistics(sf::RenderWindow *window, const std::string& turn, const std::string& sizeBoatMoi,
const std::string& sizeBoatIa, const std::string& nbBoatMoi, const std::string& nbBoatIa);

private:
sf::Font font;
Expand Down
3 changes: 2 additions & 1 deletion Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ void Game::mainLoop(sf::RenderWindow *window)
blitText.blitStaticText(window);
blitText.tailleComposants(window);
blitText.blitStatistics(window, sTurn, moi.plat.sBateaux(moi.plat.nbBateaux(moi.plat.getCheckerboard())),
ia.plat.sBateaux(ia.plat.nbBateaux(ia.plat.getCheckerboard())));
ia.plat.sBateaux(ia.plat.nbBateaux(ia.plat.getCheckerboard())), moi.plat.printNbBateaux(),
ia.plat.printNbBateaux());
window->draw(moi.plat);
window->draw(tmp.plat);
//window->draw(ia.plat);
Expand Down
Binary file modified Naval_C
Binary file not shown.

0 comments on commit 1949b43

Please sign in to comment.