import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
import javafx.util.Duration;

public class BulletTracker extends Application {
    private static final int BULLET_SPEED = 5;
    private static final int BULLET_RADIUS = 5;
    private static final int TRAVERSAL_DISTANCE = 100;

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Bullet Tracker");
        Group root = new Group();
        Scene scene = new Scene(root, 800, 600, true);
        scene.setFill(Color.BLACK);
        primaryStage.setScene(scene);
        primaryStage.show();

        Circle bullet = new Circle(400, 300, BULLET_RADIUS);
        bullet.setFill(Color.WHITE);
        root.getChildren().add(bullet);

        Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), event -> {
            bullet.setCenterX(bullet.getCenterX() + BULLET_SPEED);
            if (bullet.getCenterX() > scene.getWidth() - BULLET_RADIUS) {
                root.getChildren().remove(bullet);
            } else {
                Line trajectory = new Line(bullet.getCenterX(), bullet.getCenterY(), bullet.getCenterX(), bullet.getCenterY() - TRAVERSAL_DISTANCE);
                trajectory.setStroke(Color.RED);
                root.getChildren().add(trajectory);
            }
        }));
        timeline.setCycleCount(Timeline.INDEFINITE);
        timeline.play();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
