Skip to content

Instantly share code, notes, and snippets.

@0xLeon
Created July 4, 2013 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 0xLeon/5929390 to your computer and use it in GitHub Desktop.
Save 0xLeon/5929390 to your computer and use it in GitHub Desktop.
Bubbles Processing
class Bubble {
float x = random(0, width);
float y = height;
void zeichnung() {
fill(0, 200, 220);
stroke(0, 127, 220);
ellipse(x, y, 20, 20);
}
void bewegung() {
y -= 1;
if (y < -20) {
y = height + 20;
}
}
}
Bubble[] bubbles = new Bubble[100];
void setup() {
size(400, 400);
background(245);
for (int i = 0; i < bubbles.length; i++) {
bubbles[i] = new Bubble();
}
}
void draw() {
background(245);
for (int i = 0; i < bubbles.length; i++) {
bubbles[i].zeichnung();
bubbles[i].bewegung();
}
}
class StrangeBubble extends Bubble {
float size = random(10, 30);
void zeichnung() {
fill(0, 200, 220);
stroke(0, 127, 220);
ellipse(x, y, size, size);
}
void bewegung() {
super.bewegung();
size -= 0.5;
if (size < 1) {
size = 20;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment