make everything one function

This commit is contained in:
Asif Bacchus 2020-04-08 05:00:04 -06:00
parent 89263b1495
commit c0e4424257

View File

@ -1,3 +1,4 @@
function particles() {
/* create particles animation /* create particles animation
based on the amazing tutorial by 'Franks Labratory' based on the amazing tutorial by 'Franks Labratory'
https://youtu.be/d620nV6bp0A https://youtu.be/d620nV6bp0A
@ -55,7 +56,7 @@ class Particle{
if (this.y > canvas.height || this.y < 0){ if (this.y > canvas.height || this.y < 0){
this.directionY = -this.directionY; this.directionY = -this.directionY;
} }
/*
// collision detection between mouse and particles // collision detection between mouse and particles
let dx = mousePosition.x - this.x; let dx = mousePosition.x - this.x;
let dy = mousePosition.y - this.y; let dy = mousePosition.y - this.y;
@ -74,7 +75,7 @@ class Particle{
this.y -= 10; this.y -= 10;
} }
} }
*/
// move particle // move particle
this.x += this.directionX; this.x += this.directionX;
this.y += this.directionY; this.y += this.directionY;
@ -157,3 +158,4 @@ window.addEventListener('mouseout', function(){
init(); init();
animate(); animate();
}