Commit 5cbaaa5d authored by Antonin Deneux's avatar Antonin Deneux Committed by Quentin DRUAULT-AUBIN
Browse files

Ajout de placeShip

parent 0d7ad7ed
......@@ -446,6 +446,40 @@ public class InGameGUIController {
}
}
void putShipOnBoard(Ship ship)
{
// We assume the ship has the right coordinates.
// Moreover, this function won't update the shipboard!
if (!gameStarted && !ship.getListCoord().isEmpty()) {
try {
// Load the image.
ImageView shipOnTheGrid = new ImageView(shipsPictures.get(ship.getType()));
if (ship.getListCoord().get(0).getY() == ship.getListCoord().get(1).getY()) {
// Horizontal.
// Set the size.
shipOnTheGrid.setFitWidth(playerGrid.getWidth()/10.0 * ship.getSize());
shipOnTheGrid.setFitHeight(playerGrid.getHeight()/10.0);
// Place on the grid.
playerGrid.add(shipOnTheGrid, ship.getListCoord().get(0).getX(), ship.getListCoord().get(0).getY(), ship.getSize(), 1);
} else {
// Vertical
// Set the size.
shipOnTheGrid.setFitHeight(playerGrid.getWidth()/10.0);
shipOnTheGrid.setFitWidth(playerGrid.getHeight()/10.0 * ship.getSize());
// Rotate the image.
shipOnTheGrid.setRotate(90);
// Place on the grid.
playerGrid.add(shipOnTheGrid, ship.getListCoord().get(0).getX(), ship.getListCoord().get(0).getY(), 1, ship.getSize());
}
} catch (Exception ex) {
Logger.getLogger(InGameGUIController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
/**
* Update the label on the ship button by adding the specified value
* Param ShipType
......
Supports Markdown
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