createWindow(w, h);
Create a GLFW window.
Arguments
w
Window widthh
Window heightIt is also possible to create a window in the global scope without defining a setup function.
function setup()
-- Create the window here
createWindow(600, 600);
end
function draw()
-- draw things
end
background(r, g, b, a);
Clear a background with a color
Arguments
r
The red byteg
The green byteb
The blue bytea
The alpha byteframeRate(fps);
Set the frame rate
Arguments
fps
The frame rate to setIf frame rate is called without an argument, it will return frame per seconds
x = 0;
function setup()
createWindow(400, 400);
frameRate(24);
end
function draw()
background(51);
text('fps: ' .. frameRate(), 20, 10);
circle(x, 200, 32);
x = x + 1;
end
deltaTime
GlobalElapsed time since the last draw call in seconds
x = 0;
vx = 128;
function setup()
createWindow(400, 400);
frameRate(24); -- try with 60
end
function draw()
background(51);
circle(x, height/2, 32);
-- Get the same velocity with different framerates
x = x + vx * deltaTime;
end