System.out.println("Enemy Health is "+Main.HealthEnemy);
if(Main.HealthEnemy<1){
if(Main.HealthEnemy<1){
System.out.println("You Win!");// Once the player reduces the enemy ships or health (same thing) to zero then they win
System.out.println("You Win!");// Once the player reduces the enemy ships or health (same thing) to zero then they win
...
@@ -150,6 +152,41 @@ cell.isShip = true;
...
@@ -150,6 +152,41 @@ cell.isShip = true;
}
}
publicvoidenemyPlace(booleanvertical,intships,intxIn,intyIn){// The array in main will make sure the ships placed will be in order of what I put them in the array and in length
System.out.println(ships);
if(vertical){
//checks selected orientation from the mouse press in this case horizontal or vertical
for(inti=yIn;i<yIn+ships;i++){
//loops all the cells the ship would cover
Cellcell=getCell(xIn,i);
cell.setFill(Color.GRAY);
//colours the squares on the grid to show a ship
cell.isShip=true;
//Marks the cells showing that a ship is present there
}
}else{
for(inti=xIn;i<xIn+ships;i++){
Cellcell=getCell(yIn,i);
cell.setFill(Color.GRAY);
cell.isShip=true;
}
}
}
/** @param vertical true if we're placing a vertical ship
/** @param vertical true if we're placing a vertical ship
...
@@ -268,6 +305,7 @@ if (enemyTarget.isShip) {
...
@@ -268,6 +305,7 @@ if (enemyTarget.isShip) {
enemyTarget.setFill(Color.ORANGE);
enemyTarget.setFill(Color.ORANGE);
Main.HealthPlayer--;
Main.HealthPlayer--;
System.out.println("Player Health is "+Main.HealthPlayer);