Help us understand the problem. What is going on with this article?

ズンドコキヨシ Processing

More than 3 years have passed since last update.

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;
  }
}

仕事をしよう

参考

feb19
Designer / Engineer http://feb19.jp
http://feb19.jp/blog
dena_coltd
    Delight and Impact the World
https://dena.com/jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした