MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / update

Function update

assets/js/snow.js:95–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93
94 var delta = 0;
95 function update() {
96 //update position of every snow
97 delta += 0.01;
98 var p;
99 for (var i = 0; i < snowGroup.length; i++) {
100 p = snowGroup[i];
101 p.y += p.s;
102 p.x += Math.sin(delta + p.xChangeRate) * p.xChangeRate;
103 if (p.x > W + p.r || p.y > H + p.r || p.x < -p.r) {
104 snowGroup[i] = initialEverySnow();
105 var randomStartPostion = Math.ceil(Math.random() * 3);
106 switch (randomStartPostion) {
107 case 1:
108 snowGroup[i].x = Math.random() * W;
109 snowGroup[i].y = -rMax;
110 break;
111 case 2:
112 snowGroup[i].x = -rMax;
113 snowGroup[i].y = Math.random() * H;
114 break;
115 case 3:
116 snowGroup[i].x = W + rMax;
117 snowGroup[i].y = Math.random() * H;
118 break;
119 }
120 }
121 }
122 }
123 setInterval(draw, 1000 / 60);
124};
125

Callers 1

drawFunction · 0.70

Calls 1

initialEverySnowFunction · 0.85

Tested by

no test coverage detected