Commit bc035332 authored by patrick.gustard-sm's avatar patrick.gustard-sm

Changed Colour so enemy ships can no longer be seen

parent 0c021340
...@@ -87,7 +87,9 @@ if (isShip == true) { ...@@ -87,7 +87,9 @@ if (isShip == true) {
//if cell contains a ship //if cell contains a ship
setFill(Color.ORANGE); setFill(Color.ORANGE);
Main.HealthEnemy --; Main.HealthEnemy --;
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;
} }
public void enemyPlace(boolean vertical, int ships, int xIn, int yIn) { // 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 (int i = yIn; i < yIn + ships; i++) {
//loops all the cells the ship would cover
Cell cell = 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 (int i = xIn; i < xIn + ships; i++) {
Cell cell = 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);
} else { } else {
......
...@@ -178,7 +178,7 @@ public class Main extends Application { ...@@ -178,7 +178,7 @@ public class Main extends Application {
//prevents placement in obstructed areas //prevents placement in obstructed areas
System.out.println("calling place at " + ComputerX + " " + ComputerY); System.out.println("calling place at " + ComputerX + " " + ComputerY);
BoardEnemy.place(aiVert,ships[enemyshipnum], ComputerX, ComputerY); BoardEnemy.enemyPlace(aiVert,ships[enemyshipnum], ComputerX, ComputerY);
//Places the ships from the board //Places the ships from the board
System.out.println(enemyshipnum); System.out.println(enemyshipnum);
//so the for Loop will count up by one //so the for Loop will count up by one
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment