Created
October 13, 2017 04:35
-
-
Save ulrichzwingli/5f1fcb8373d9fceb06ac8b80a2f58446 to your computer and use it in GitHub Desktop.
fire_cracker_when_Mouse_Pressed_at_MouseX_MouseY
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
var balls = []; | |
var angle = [0,30,60,90,120,150,180,210,240,270,300,330,360]; | |
function setup() { | |
createCanvas(400,400); | |
} | |
function mousePressed() { | |
balls.push(new Cracker()); | |
} | |
function draw() { | |
background(0); | |
for(i=0; i<balls.length; i++) { | |
balls[i].ballDia(); | |
balls[i].display(); | |
} | |
} | |
function Cracker() { | |
this.x= mouseX; | |
this.y= mouseY; | |
this.dia1= 40; | |
this.k=0; | |
this.p= 0; | |
this.display= function() { | |
//for(p=0; p<angle.length; p++) { | |
if (this.p<12) { | |
fill(255,0,0); | |
ellipse(this.x, this.y, this.dia1, this.dia1); | |
this.x += cos(angle[this.p]*0.0174533); | |
this.y += sin(angle[this.p]*0.0174533); | |
this.p++; | |
} | |
} | |
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; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment