pluto
i actually made something like this a while ago for a SAP recreation(needed pets to throw stuff like food and rocks at each other)
i didn't wanna learn the math and whatnot so i brute forced this together:
function calcThrow(x,y,vy,tx,ty,g){
y += vy;
var mult = 1;
var count = (-vy*2*mult);
while(dist(x,y,x,ty)<= vy||vy < 0){
vy += g;
count += 1;
}
if(tx > x){
return(dist(x,y,tx,ty)/count);
}else{
return(-(dist(x,y,tx,ty)/count));
}
}
what it does is intakes two positions and a given y velocity(-5 for example), a gravity amount(what the y velocity increases by every frame), and returns what x velocity the projectile needs to reach the other position.
not efficient i think, but hey it works
you can see this work in this WIP:
https://www.khanacademy.org/computer-programming/new-program2/6395378813943808