im making a sort of system for grenades of where you throw them, they go in a perfect arch.
thing is, i don't know how.
so please help me.

p = player
t = trajectory or landing whatever

    hmm.... perhaps something like this might work?

    var height = 12;
    var width = 96;
    function arcRadii(w, h) {
    return (Math.pow(w, 2) + Math.pow(h, 2)) / (2 * h);
    }

    though I'm not completely sure if arc takes radius into account though

    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

    Letti42 ok so how do i implement this of where they press a key it creates a sprite, as i cannot find a way to do that

    Letti42 ok so how do i implement this of where they press a key it creates a sprite, as i cannot find a way to do that

      pluto I changed the code, it should show how now.

        Letti42 thanks but...
        i have bad news.
        my account legit got deleted when i got back from lunch for no reason

        💀 bro i think acks right khan is better
        why cdo do that

          Chat