Skip to content

Instantly share code, notes, and snippets.

@memish
Created November 26, 2018 00:58
Show Gist options
  • Save memish/8d6d3884e7d1521644a8f2dc02f5b986 to your computer and use it in GitHub Desktop.
Save memish/8d6d3884e7d1521644a8f2dc02f5b986 to your computer and use it in GitHub Desktop.
ArrayList<Bub> b = new ArrayList<Bub>();
boolean press = false;//you will want to use this
void setup(){
size(600,400);
}
void draw()
{
background(0);
for(int i = 0; i<b.size(); i++){
Bub cir = b.get(i);
fill(255,0,0);//how can you make this dynamic
ellipse(cir.x,cir.y, 10,10);
//how can you move the bubbles - do that here
}
}
//everytime you need to create a new bubble
//call this method
public void addBubbles(){
Bub bb = new Bub(mouseX, mouseY);
b.add(bb);
}
void mousePressed(){
addBubbles();//you will want to move this from here
}
void mouseReleased(){
}
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;
/* initialize other variables here */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment