How to make this simulation better?

    var camX;
    var camY;
    var camZ;
    var Vox = 0;
    var aZ = 0;
    var k = 400;
    var m = 400;
    var n = 400;
    var t1 = 0;

    function setup() 
    {createCanvas(windowWidth, windowHeight, WEBGL);}

    function draw(){
    camX = map(m, 0, width,-200,200);
    camY = map(k, 0, width,-200,200);
    camZ = map(n, 0, width,-200,200);   
    fill (0,0,255);

    t1 =  0.7
    aZ = accelerationZ;
    S1 = Vox*t1 + (aZ*t1*t1)/2;
    if (aZ>-0.2 && aZ<0.2) {Vox = 0}
    else {Vox = Vox + aZ*t1;}
    k = k + S1;
    S1 = 0;}

it is not a duplicate of my question. my previous one was different and it was marked as answered, while it was not

This program was made to simulate the movement to and away from the cube. Now I have a problem with it. When I move away from the "cube", everything is okay and the cube becomes smaller, but when I stop, the acceleration becomes positive and the cube becomes bigger instead of staying with no changes. I can't find the solution for this. How to do it???



Sign In or Register to comment.