Skip to content

Commit

Permalink
Small graphics fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bleznudd committed Jan 1, 2018
1 parent 4f281d5 commit 22462df
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main(){
graphic::clear();
graphic::gohome();
graphic::title("BATTAGLIA NAVALE");
cout << " ********************************************************** " << endl;
cout << " ********************************************************** " << endl;
cout << " Benvenuti a battaglia navale, per cominciare inserite i nomi dei giocatori " << endl;
cout << endl;

Expand All @@ -27,7 +27,7 @@ int main(){
graphic::up(5);

//ISTRUZIONI
cout << " ************************* ISTRUZIONI ************************* " << endl
cout << " *********************** ISTRUZIONI ************************* " << endl
<< "Generali" << endl
<< " Il gioco si svoglie in una griglia 10x10 caselle numerate 0-9." << endl
<< " Una posizione va indicata con 2 numeri separati da virgola (y,x)." << endl
Expand Down
10 changes: 4 additions & 6 deletions source/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ void Player::UpdateShipnum(){
}
void Player::Deploy(){
Draw();
int surpluslines=0;
cout << "Schieramento della flotta del giocatore " << name << ": ";
while(shipnum[0] > 0){
int surpluslines=0;
Point pi, pf;
cout << endl << "Inserisci il punto iniziale della tua nave: ";
while(!(cin >> pi)) {
Expand All @@ -71,16 +71,14 @@ void Player::Deploy(){
}
if(ShipFactory::create(pi, pf, this) == true){
UpdateShipnum();
graphic::up(surpluslines+16);
graphic::up(surpluslines+15);
fleetVisible(true);
Draw();
surpluslines = 0;
}
else{
cout << endl;
graphic::up(1);
cout << "L' intervallo di punti non corrisponde a nessun tipo di nave disponibile, riprovare";
surpluslines=+2;

surpluslines+=3;
}
}
fleetVisible(false);
Expand Down
23 changes: 6 additions & 17 deletions source/ShipFactory.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "../header/ShipFactory.h"
#include "../header/Graphic.h"
#include <algorithm> //per std::swap in ShipFactory::create()
#include <algorithm>//--------------------> per std::swap in ShipFactory::create()

using namespace std;
using graphic::up;

ShipFactory::ShipFactory(){
Expand Down Expand Up @@ -29,7 +30,6 @@ bool ShipFactory::create(Point pstart, Point pend, Player* currentp){
}
}
else{
graphic::up(3);
return false;
}

Expand All @@ -38,54 +38,45 @@ bool ShipFactory::create(Point pstart, Point pend, Player* currentp){
switch(len){
case 2:
if(currentp->shipnum[1]>0){
//currentp->shipnum[1]--;
ship = new Destroyer(pstart,pend);
cout << "Creato cacciatorpediniere" << endl;
//cout << "Creato cacciatorpediniere" << endl;
creation=true;
}
else{
graphic::up(3);
return false;
}
break;
case 3:
if(currentp->shipnum[2]>0){
//currentp->shipnum[2]--;
ship = new Cruiser(pstart,pend);
cout << "Creato cacciatorpediniere" << endl;
//cout << "Creato cacciatorpediniere" << endl;
creation=true;
}
else{
graphic::up(3);
return false;
}
break;
case 4:
if(currentp->shipnum[3]>0){
//currentp->shipnum[3]--;
ship = new Battleship(pstart,pend);
cout << "Creato cacciatorpediniere" << endl;
//cout << "Creato cacciatorpediniere" << endl;
creation=true;
}
else{
graphic::up(3);
return false;
}
break;
case 5:
if(currentp->shipnum[4]>0){
//currentp->shipnum[4]--;
ship = new Carrier(pstart,pend);
cout << "Creato cacciatorpediniere" << endl;
//cout << "Creato cacciatorpediniere" << endl;
creation=true;
}
else{
graphic::up(3);
return false;
}
break;
default:
graphic::up(3);
return false;
break;
}
Expand All @@ -97,7 +88,6 @@ bool ShipFactory::create(Point pstart, Point pend, Player* currentp){
if(**iter==currentp->map[i][j]){
if(currentp->map[i][j].getShippoint()==true){
creation=false;
graphic::up(3);
}
else if(creation == true){
currentp->map[i][j].setShippoint(true);
Expand All @@ -113,7 +103,6 @@ bool ShipFactory::create(Point pstart, Point pend, Player* currentp){
}
else{
delete ship;
graphic::up(1);
}
return creation;
}

0 comments on commit 22462df

Please sign in to comment.