Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Last active January 10, 2017 04:26
Show Gist options
  • Save sasaki-shigeo/7744456 to your computer and use it in GitHub Desktop.
Save sasaki-shigeo/7744456 to your computer and use it in GitHub Desktop.
Demonstration of snow falling /Processing による雪の降下デモ
class Crystal {
float x, y, phi;
Crystal(float x0, float y0, float phi0) {
x = x0;
y = y0;
phi = phi0;
}
void fall() {
y++;
}
void show() {
noStroke();
ellipse(x, y, phi, phi);
}
}
ArrayList<Crystal> crystals = new ArrayList<Crystal>(100);
void setup() {
size(500, 500);
for (int i = 0; i < 100; i++) {
crystals.add(new Crystal(random(width), random(height), 20));
}
}
void draw() {
background(180);
for (Crystal x: crystals) {
x.show();
x.fall();
}
}
void mouseReleased() {
crystals.add(new Crystal(mouseX, mouseY, 20));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment