Skip to content

Instantly share code, notes, and snippets.

@atsjj
Created September 16, 2020 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atsjj/149b4af548418a5abc7de21cc1f69766 to your computer and use it in GitHub Desktop.
Save atsjj/149b4af548418a5abc7de21cc1f69766 to your computer and use it in GitHub Desktop.
p5js scene state
let currentScene = 1;
function setup() {
createCanvas(400, 400);
}
function mouseClicked() {
if (currentScene == 1) {
currentScene = 2;
} else {
currentScene = 1;
}
}
function draw() {
background(220);
if (currentScene == 1) {
scene1();
}
if (currentScene == 2) {
scene2();
}
}
function scene1() {
background(0,0,0);
}
function scene2() {
background(100,100,50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment