frameRate

v0.1.7
frameRate(fps);

Set the frame rate.

Arguments

fpsThe frame rate to set

If frame rate is called without an argument, it will return frame per seconds

x = 0;
r = 16;
speed = 50;

function setup()
  createWindow(200, 200);

  frameRate(30); -- Set the frame rate
end

function draw()
  background('purple');
  text('fps: ' .. frameRate(), 20, 30);

  square(x, 100, r);
  if x > width+r then 
    x = -r;
  else
    x = x + speed * deltaTime;
  end
end

Output

x = 0;
r = 16;
speed = 50;

function setup()
  createWindow(200, 200);

  frameRate(12); -- Set the frame rate
end

function draw()
  background('purple');
  text('fps: ' .. frameRate(), 20, 30);

  square(x, 100, r);
  if x > width+r then 
    x = -r;
  else
    x = x + speed * deltaTime;
  end
end

Output

See frameRate in window.h