var piece = {
// this.x = CordsUpdate.x;
// this.y = CordsUpdate.y;
x: undefined,
y: undefined,
radius: undefined,
motionX: undefined,
motionY: undefined,
Part() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.radius = Math.random() * 5 + 1;
this.motionX = Math.random() * 3 - 1.5;
this.motionY = Math.random() * 3 - 1.5;
},
//which direction circle going
motion() {
this.x += this.motionX;
this.y += this.motionY;
},
//creating a circle
draw() {
var colors = ["#780000", "#c1121f", "#fdf0d5", "#003049", "#669bbc"];
// context.fillStyle = colors[Math.round(Math.random() * colors.length - 1)];
context.fillStyle = "whitesmoke";
context.beginPath();
context.arc(this.x, this.y, this.radius, 0, 2 * Math.PI);
context.fill();
},
};
PartArray = [];
//make particles
function start() {
for (let i = 0; i < 100; i++) {
PartArray.push(piece.Part());
}
}
start();
console.log(PartArray);