Edited at

ズンドコキヨシ Processing

More than 3 years have passed since last update.


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


仕事をしよう


参考