Skip to content

Commit d822a65

Browse files
committed
add moving cloud depicting a scene
1 parent 4d33bef commit d822a65

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

src/weather.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
var CC, RN, WD, SM, cloud, sunMoon, wind, rain, currentTime;
2+
var diffInWeatherTime = 10;
3+
function Cloud() {
4+
this.color = 'blue';
5+
this.x = G.can.width || P.w;
6+
this.y = 100;
7+
this.speed = 7;
8+
this.update();
9+
}
10+
Cloud.prototype = {
11+
update: function () {
12+
this.x -= this.speed;
13+
if (this.x + 250 < 0) {
14+
this.x = CC.w;
15+
this.y = this.y + utils.getRandomInt(-10, 10);
16+
}
17+
18+
var cloudColor = thisWeather.hexToRgb(thisWeather.getColor(), 0.5);
19+
20+
sv();
21+
bp();
22+
fs(cloudColor)
23+
mt(this.x, this.y);
24+
bct(this.x - 40, this.y + 20, this.x - 40, this.y + 70, this.x + 60, this.y + 70);
25+
bct(this.x + 80, this.y + 100, this.x + 150, this.y + 100, this.x + 170, this.y + 70);
26+
bct(this.x + 250, this.y + 70, this.x + 250, this.y + 40, this.x + 220, this.y + 20);
27+
bct(this.x + 260, this.y - 40, this.x + 200, this.y - 50, this.x + 170, this.y - 30);
28+
bct(this.x + 150, this.y - 75, this.x + 80, this.y - 60, this.x + 80, this.y - 30);
29+
bct(this.x + 30, this.y - 75, this.x - 20, this.y - 60, this.x, this.y);
30+
cp();
31+
32+
ctx.shadowColor = thisWeather.hexToRgb(thisWeather.getColor(), 0.8);
33+
ctx.shadowOffsetX = -3;
34+
ctx.shadowOffsetY = 3;
35+
ctx.shadowBlur = 10;
36+
ctx.lineWidth = 3;
37+
sts(thisWeather.hexToRgb(thisWeather.getColor(), 0.8))
38+
st();
39+
fl();
40+
rs();
41+
42+
bp();
43+
mt(this.x + 150, this.y - 15); // 188, 50
44+
qct(
45+
this.x + 150 + 50,
46+
this.y - 15 + 0,
47+
this.x + 150 + 40,
48+
this.y - 15 + 40
49+
);
50+
ctx.lineWidth = 4;
51+
sts(thisWeather.hexToRgb(thisWeather.getColor(), 0.8))
52+
st();
53+
54+
bp();
55+
mt(this.x + 20 + 30, this.y + 10); // 188, 50
56+
qct(
57+
this.x + 30,
58+
this.y + 35 + 10,
59+
this.x + 30 + 60,
60+
this.y + 35 + 15
61+
);
62+
st();
63+
}
64+
}

0 commit comments

Comments
 (0)