Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- declare variables
- initialize variables
- methods
- */
- class Bubble {
- //declare variables
- float x;
- float y;
- float diameter;
- Bubble() {
- //initialize variables
- diameter = random(-100, 50);
- x = width/2 + random(-200, 200);
- y = height-diameter/2;
- }
- //methods
- void display() {
- //background(255);
- ellipse(x, y, diameter, diameter);
- }
- void ascend() {
- y--;
- }
- void top() {
- if (y<(diameter/2))
- y=diameter/2;
- }
- }
- //you can create a new tab at the top of processing
- //thats where this code goes
- Bubble b1, b2;
- void setup() {
- size(640, 360);
- b1 = new Bubble();
- b2 = new Bubble();
- }
- void draw() {
- background(255);
- b1.display();
- b1.ascend();
- b1.top();
- b2.display();
- b2.ascend();
- b2.top();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement