Calling functions with variables

Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#method-java.lang.String-

// https://Discourse.Processing.org/t/calling-functions-with-variables/30001/4
// GoToLoop (2021/May/09)

static final String SCENE = "scene";

void setup() {
  noLoop();
}

void draw() {
  background((color) random(#000000));
  final int chosenScene = (int) random(1, 4);
  method(SCENE + chosenScene);
}

void mousePressed() {
  redraw();
}

void scene1() {
  println(SCENE, 1);
}

void scene2() {
  println(SCENE, 2);
}

void scene3() {
  println(SCENE, 3);
}
5 Likes