q5play
    Preparing search index...

    Variable deltaTime

    deltaTime: number

    💻 The time passed since the last frame was drawn.

    With the default frame rate of 60, delta time will be approximately 16.6

    Can be used to keep movements tied to real time if the sketch is often dropping below the target frame rate. Although if frame rates are consistently low, consider reducing the target frame rate instead.

    q5.draw = function () {
    background(0.8);
    text(deltaTime, -90, 6);
    };
    let x = -100;
    q5.draw = function () {
    background(0.8);
    // simulate frame rate drops
    frameRate(random(30, 60));

    x += deltaTime * 0.2;
    if (x > 100) x = -100;
    circle(x, 0, 20);
    };