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(){
    background(90); 
    camX = map(m, 0, width,-200,200);
    camY = map(k, 0, width,-200,200);
    camZ = map(n, 0, width,-200,200);   
    camera(-camY+300,0,-camY+200,-camZ,camX,0,0,-1,0)   
    fill (0,0,255);
    box(150);

    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???

Tagged:

Answers

Sign In or Register to comment.