import java.awt.*;
import javax.swing.*;

public class BulletTrackingExample extends JFrame {
    private int bulletX;
    private int bulletY;
    private int targetX;
    private int targetY;
    
    public BulletTrackingExample() {
        bulletX = 0;
        bulletY = 0;
        targetX = 200;
        targetY = 200;
        
        setTitle("Bullet Tracking Example");
        setSize(400, 400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.setColor(Color.RED);
        g.fillOval(bulletX, bulletY, 10, 10);
        g.setColor(Color.BLUE);
        g.fillOval(targetX, targetY, 20, 20);
        
        int dx = targetX - bulletX;
        int dy = targetY - bulletY;
        
        
        int speed = 5;
        
   
        bulletX += (dx / speed);
        bulletY += (dy / speed);
        
        
        if (Math.abs(dx) < 10 && Math.abs(dy) < 10) {
            g.drawString("Target Hit!", 150, 20);
        }
        

        repaint();
    }
    
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new BulletTrackingExample();
            }
        });
    }
}
