Bubbles 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 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; | |
} | |
} | |
} |
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
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(); | |
} | |
} |
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 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