LoginSignup
7
7

More than 5 years have passed since last update.

ズンドコキヨシ Processing

Last updated at Posted at 2016-03-18

motion3.gif

zundoko_sketch.pde
String zun = "ZUN";
String doko = "DOKO";
String kiyoshi = "KI YO SHI!";
String[] expectedReversed = {doko, zun, zun, zun, zun};
String[] history = {};
Boolean preservedShout = false;
Boolean shouted = false;

void setup() {
  size(360, 360);
  background(255);
  frameRate(4);
}
String shout() {
  if (random(1.0) < 0.5) {
    return zun;
  } else {
    return doko;
  }
}
void draw() {
  if (shouted) return;

  background(255);

  float fontSize = random(48)+24; 
  String output = shout();
  if (preservedShout) {
    output = kiyoshi;
    shouted = true;
    fontSize = 70;
  }
  history = (String[])append(history, output);

  Boolean isExpected = false;
  if (history.length >= 5) {
    int count = 0;
    isExpected = true;
    for (int i = history.length-1; i >= history.length - 5; i--) {
      if (expectedReversed[count] != history[i]) {
        isExpected = false;
      }
      count++;
    }
  }
  fill(0);
    textAlign(CENTER);
    textSize(fontSize);
    text(output, width/2, height/2 + fontSize/4);
  noFill();

  if (isExpected) {
    preservedShout = true;
  }
}

仕事をしよう

参考

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7