For my school project i have to make a game where a cannon have to shoot a bullet to a airplane, the problem is, when we shoot we can see all the position (X . Y) of the bullet on console but the bullet doesn't update on the UI
Here's the Test code:
vel = Slider.getValue();
double angle = panelNero.getRotate();
boolean dead = false;
while (dead == false) {
double X = P.getLayoutX();
double Y = P.getLayoutY();
if (X > 1 && Y > 1 && X < MP.getWidth() && Y < MP.getHeight()) {
System.out.println("x: " + X + " y: " + Y + " maxX: " + MP.getWidth() + " maxY: " + MP.getHeight());
double x = P.getLayoutX();
double y = P.getLayoutY();
P.setLayoutX(x += (Math.cos(Math.toRadians(angle)) * vel));
P.setLayoutY(y += (Math.cos(Math.toRadians(angle)) * vel));
System.out.println("VIVO");
try {
TimeUnit.MILLISECONDS.sleep(500);
} catch (InterruptedException ex) {
Logger.getLogger(FileFXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
System.out.println("MORTO");
P.setLayoutX(pro.posX);
P.setLayoutY(pro.posY);
dead = true;
}
}