Add ball and move it with cursor until a line

hey guys!
first of all i want to create the game skee ball in processing.
i already have a ball as cursor but i want that the ball is fly after throwing line and not be fixed on the cursor.

my code atm:
int wurfstaerke = 50;
int gesamtpunktzahl = 0;
boolean geworfen = false;
int mouseXTemp;
int mouseYTemp;
PImage hintergrund, loch1, loch2, loch3, loch4, loch5, ball;

void setup() {
size(400, 600);
hintergrund = loadImage(“assets/images/background.jpg”);
}

void draw() {
background(hintergrund);

// zielwurfzonen
drawCircles();
loch1 = loadImage(“assets/images/loch.png”);
image(loch1, 80, 10);
loch2 = loadImage(“assets/images/loch.png”);
image(loch2, 240, 10);
loch3 = loadImage(“assets/images/loch.png”);
image(loch3, 160, 70);
loch4 = loadImage(“assets/images/loch.png”);
image(loch4, 160, 150);
loch5 = loadImage(“assets/images/loch.png”);
image(loch5, 160, 225);

// beschriftung zielwurfzone
drawText();
textSize(11);
text(“100”, 99, 90);
text(“100”, 260, 90);
text(“50”, 180, 140);
text(“40”, 180, 220);
text(“30”, 180, 295);

// wurfline
line(0, 300, width, 300);

// ball zeichnen
drawBall();
ball = loadImage(“assets/images/ball.png”);
cursor(ball);

// distanz berechnen
calculateDistance();
}

void drawCircles() {
fill(100);
rect(10,500,180,20);
fill(255);
rect(10,520,180,50);
}

void drawText() {
fill(0);

textSize(11);
text(“100”, 520, 50);

textSize(14);
text("Wurfstärke: " + wurfstaerke, 10, 590);
}

void calculateDistance() {
// distanz des Balls zu den Wurfzonen
}

void drawBall() {
}

void keyPressed() {
if (key == ‘+’) {
wurfstaerke++;
}
else
if (key == ‘-’) {
wurfstaerke–;
}
}

void mousePressed() {}

one remark: please load all assets in setup (which runs only once) and not in draw (which runs 60 times per second)

to achieve what you want: do you want to release the ball in any direction? Using the mouse?

Then look

  • at atan2 in the reference for the angle
  • at dist() for the distance
  • and at function mouseReleased() to start the flying of the ball.

please use <code></code> or
```language-name(optional)
//Your code
```
or just two backticks for inline code see Markdown Tutorial - Code