Last active
January 10, 2017 04:26
-
-
Save sasaki-shigeo/7744456 to your computer and use it in GitHub Desktop.
Demonstration of snow falling /Processing による雪の降下デモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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