Created
September 16, 2020 00:16
-
-
Save atsjj/149b4af548418a5abc7de21cc1f69766 to your computer and use it in GitHub Desktop.
p5js scene state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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