-
Notifications
You must be signed in to change notification settings - Fork 0
/
city.html
executable file
·191 lines (158 loc) · 5.45 KB
/
city.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<html>
<head>
<title>GWC Graphics and Animation Week!</title>
<script src="http://cloud.github.com/downloads/processing-js/processing-js/processing-1.4.1.min.js"></script>
<script type="text/processing" data-processing-target="mycanvas">
myBuilding building;
myCloud cloud;
noStroke();
row1 = [];
row2 = [];
row3 = [];
cloud = [];
void setup()
{
//numBuild = random(1, 10);
p = 0;
background(184, 220, 255);
size(1380,820);
for (int i = 0; i < 6; i++)
{
//myCloud(x, y, width, height)
MyCloud cloud1 = new myCloud(random(10,1300), random(50,300), 200, 110);
cloud.push(cloud1);
}
for (int i = 0; i < 11; i++)
{
p = 138*i;
//myBuilding(row, width, height, xLocation, yLocation)
MyBuilding building1 = new myBuilding(1, 138, 820, p, random(105, 305));
row1.push(building1);
}
for (int i = 0; i < 9; i++)
{
p = 172.5*i;
//myBuilding(row, width, height, xLocation, yLocation)
MyBuilding building2 = new myBuilding(2, 172.5, 820, p, random(310,510));
row2.push(building2);
}
for (int i = 0; i < 7; i++)
{
p = 230*i;
MyBuilding building3 = new myBuilding (3, 230, 820, p, random(515,715));
row3.push(building3);
}
}
void draw()
{
background(184, 220, 255);
fill(255,225,0);
ellipse(1000, 70, 100, 100);
for (int i = 0; i < cloud.length; i++)
{
myCloud currCloud = cloud[i];
fill (255,255,255)
currCloud.drawCloud();
currCloud.move();
if (cloud[i].myX > 1380)
{
cloud[i].myX = -138
}
}
for (int i = 0; i < row1.length; i++)
{
//myFish = fishes(myFish)fishes.get(i);
myBuilding currBuild = row1[i];
fill (144,144,144);
currBuild.drawBuild();
currBuild.move();
if (row1[i].myX > 1380)
{
row1[i].myX = -138
}
}
for (int i = 0; i < row2.length; i++)
{
//myFish = fishes(myFish)fishes.get(i);
myBuilding currBuild = row2[i];
fill(91, 91, 91);
currBuild.drawBuild();
currBuild.move2();
if (row2[i].myX > 1380)
{
row2[i].myX = -172.5
}
}
for (int i = 0; i < row3.length; i++)
{
myBuilding currBuild = row3[i];
fill (0,0,102);
currBuild.drawBuild();
currBuild.move3();
if (row3[i].myX > 1380)
{
row3[i].myX = -230
}
}
}
class myBuilding
{
var myRow;
var myWidth;
var myHeight;
var myX;
var myY;
myBuilding(row, width, height, xLocation, yLocation)
{
myRow = row;
myWidth = width;
myX = xLocation;
myY = yLocation;
myHeight = height;
}
void move()
{
myX+=1;
}
void move2()
{
myX+=2;
}
void move3()
{
myX+=3;
}
void drawBuild()
{
rect(myX,myY,myWidth,myHeight);
}
}
class myCloud {
var myX;
var myY;
var myWidth;
var myHeight;
myCloud(x, y, width, height)
{
myX = x;
myY = y;
myWidth = width;
myHeight = height;
}
void move()
{
myX+=0.5;
}
void drawCloud()
{
ellipse(myX, myY, myWidth, myHeight);
ellipse(myX+50, myY, myWidth-20, myHeight-30);
ellipse(myX-50, myY, myWidth-20, myHeight-30);
}
}
</script>
</head>
<body>
<canvas id="mycanvas"></canvas>
</body>
</html>