Skip to content

Instantly share code, notes, and snippets.

@takawo
Last active December 24, 2015 23:26
Show Gist options
  • Save takawo/f93f9052a34327a71f07 to your computer and use it in GitHub Desktop.
Save takawo/f93f9052a34327a71f07 to your computer and use it in GitHub Desktop.
ArrayList<Type> types = new ArrayList<Type>();
PFont font;
void setup() {
size(960, 540);
colorMode(HSB, 360, 100, 100);
noStroke();
fill(0, 0, 0);
font = createFont("System San Francisco Display Bold.ttf", 64);
textAlign(CENTER,CENTER);
String str = "TYPE FOUNTAIN";
for (int i = 0; i < str.length(); i++) {
types.add(new Type(str(str.charAt(i))));
}
}
void draw() {
background(0, 0, 100);
if (types.size() < 1) {
fill(0,0,50);
textSize(16);
text("TYPE SOME KEYBOARDS...",width/2,height/2);
}
ArrayList<Type> removeList = new ArrayList<Type>();
for (Type t : types) {
t.update();
t.display();
if (t.pos.y > height+64) {
removeList.add(t);
}
}
for (Type t : removeList) {
types.remove(t);
}
}
void keyPressed() {
Type t = new Type(str(key).toUpperCase());
types.add(t);
}
class Type {
PVector pos;
PVector speed;
PVector gravity;
String str;
float angle;
float size;
public Type(String str) {
pos = new PVector(width/2, height);
speed = new PVector(random(10)-5, -random(10, 15));
gravity = new PVector(0, random(0.2, 0.25));
this.str = str;
angle = random(TWO_PI);
size = random(32, 128);
}
public void update() {
speed.add(gravity);
pos.add(speed);
}
public void display() {
pushMatrix();
translate(pos.x, pos.y);
rotate(angle+frameCount*0.03);
fill(0, 0, 0);
textSize(size);
text(str, 0, 0);
popMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment