Skip to content

Instantly share code, notes, and snippets.

@memish
Created November 26, 2018 01:33
Show Gist options
  • Save memish/2b24bc0c1456f82cff962ec8fc307837 to your computer and use it in GitHub Desktop.
Save memish/2b24bc0c1456f82cff962ec8fc307837 to your computer and use it in GitHub Desktop.
ArrayList<Bub> b = new ArrayList<Bub>();
boolean press = false;
void setup(){
size(600,400);
}
void draw()
{
background(0);
for(int i = 0; i<b.size(); i++){
Bub cir = b.get(i);
fill(cir.c);
ellipse(cir.x,cir.y, cir.r,cir.r);
// cir.x represents the x value of the bubble
//cir.sx; represents the speed for the x axis
// there is also a cir.y and a cir.sy;
//how can we use these values to make the bubbles
//move about the screen?
}
addBubbles();
}
public void addBubbles(){
if(press==true){
Bub bb = new Bub(mouseX, mouseY);
b.add(bb);
}
}
void mousePressed(){
press=true;
}
void mouseReleased(){
press=false;
}
public class Bub{
int x;
int y;
int r;
int sx;//speed
int sy;
color c;
public Bub(int x, int y){
this.x = x;
this.y = y;
sx = (int) random(-10,10);
sy = (int) random(-10,10);
//How can we alter above code to avoid
//producing a random zero??
r = 20;//how can we make the size of the bubble random?
//how can we alter code below to make the color random?
c = color(255,0,0);
//remember color(r,g,b) r,g,b each represent numbers between
//zero and 255.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment