Help, Programming Trajectory Logic

E

Eric L

Guest
Hi, Im trying to program a trajectory plotting script for a 2D space game. The trajectory is the combination of two thrusters and a cannon that add to the momentum of a ship over time. Example

right now the plot circles update over time the same way the ship would using motion_add

Code:
if(hold)
{
    GUI_Ship.xmod = 0;
    counter++;
    speed = 0;
    
    if(counter >= plotSend)
    {
        counter = 0;   
        var plot = instance_create(x,y,Obj_PlotPoint);
        plot.direction = holdDir;
        plot.speed = holdSpeed;
    }
    
    if(Rocket_A.rocketActive)
        with(Obj_PlotPoint){motion_add(Rocket_A.image_angle,Rocket_A.rocketAccel);}
    if(Rocket_B.rocketActive)
        with(Obj_PlotPoint){motion_add(Rocket_B.image_angle,Rocket_B.rocketAccel);}
    if(ShipCannon.gunActive)
        with(Obj_PlotPoint)
        {
            if(gunEffect == false)
            {
                gunEffect = true;
                motion_add(ShipCannon.image_angle,ShipCannon.gunAccel);
            }
        }
}
Im wanting to make it update instantly instead of having to wait for a moment for the circles to move based on the momentum, but am having a lot of trouble figuring out the logic for it.
Any pointers in the right direction would be really appreciated
Thank you for your time
 

Attachments

H

Harrison Vanderbyl

Guest
if your plotting a static(like prediction) path you could use calculus
for example:

1/2*a*t*t is the equation for the distance covered over time factoring acceleration

this is a script off the top of my head
assuming no rotation of thrust vectors

accellerationx = length_dirx(rocket_a.image_angle,rocket_a.acceleration)+length_dirx(rocket_b.image_angle,rocket_b.acceleration)
accellerationy = length_diry(rocket_a.image_angle,rocket_a.acceleration)+length_diry(rocket_b.image_angle,rocket_b.acceleration)
for(time = 0;time < 10 ;time ++){
xx = 0.5*accelerationx*time*time
yy = 0.5*accelerationy*time*time
draw_circle(xx,yy)
}
 
Top