Skip to content

Instantly share code, notes, and snippets.

@ulrichzwingli
Created October 13, 2017 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulrichzwingli/a84eb2844b56c5b8ce303e8327faa6e8 to your computer and use it in GitHub Desktop.
Save ulrichzwingli/a84eb2844b56c5b8ce303e8327faa6e8 to your computer and use it in GitHub Desktop.
Fire_Cracker_at_centre
var balls = [];
var angle = [0,30,60,90,120,150,180,210,240,270,300,330];
function setup() {
createCanvas(400,400);
for(i=0; i<12; i++) {
balls[i] = new Cracker();
}
}
//function mousePressed() {
// }
//}
function draw() {
background(0);
for(i=0; i<angle.length; i++) {
balls[i].scatter();
balls[i].ballDia();
balls[i].display();
}
}
function Cracker() {
this.x= 200;
this.y= 200;
this.dia1= 40;
this.k=0;
this.r=255;
this.g=0;
this.b=0;
this.display= function() {
fill(this.r,this.g,this.b);
ellipse(this.x, this.y, this.dia1, this.dia1);
}
this.ballDia= function() {
if(this.dia1>0) {
this.dia1 -= 0.6;
}
else {
//this.k +=1;
if(this.k<=0) {
this.k+=1;
this.r = 0;
this.g = 255;
//this.b = random(0,255);
this.dia1 = 40;
this.x = 200;
this.y = 200;
}
}
}
this.scatter= function() {
this.x += cos(angle[i]*0.0174533);
this.y += sin(angle[i]*0.0174533);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment