Double hit on object collision and repeat trigger

It’s no solution to one of your Problems but you can save a little code if you use the dist function.
It can directly calculate the distance between two points.

dist(x1,y1,x2,y2)=sqrt(sq(x1-x2)+sq(y1-y2));

A thing you can try is taking the velocity of the buoy and make a loop with checks every Pixel on the way.
The look will look like this

for(int i=0;i<=dist(x,y,vx,vy);i++){}

And the point to check is.

x1+vx*i/dist(x,y,vx,vy),y1+vy*i/dist(x,y,vx,vy)
1 Like