-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyscript.pde
317 lines (255 loc) · 5.98 KB
/
myscript.pde
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
var box;
void setup()
{
size(800,800);
background(0, 204, 204);
box = new Box(100, 100, -2);
}
void draw()
{
background(0,204,204);
box.drawBox();
}
class Box
{
var xPosition;
var yPosition;
var speedX;
Box(xPos, yPos, xSpeed)
{
xPosition = xPos;
yPosition = yPos;
speedX = xSpeed;
}
void drawBox()
{
noStroke();
fill(230, 186, 76);
rect(xPosition+10,yPosition+310, 60,60); //the actual yellow box
//arrow for box
fill(18, 1, 1);
rect(xPosition+35,yPosition+340,10,30); //arrow's stick
triangle(xPosition+25,yPosition+350,xPosition+55,yPosition+350,xPosition+40,yPosition+330); //triangle of the arrow
}
void moveBox()
{
xPosition = xPosition + speedX;
if(xPosition < 2)//when the house is off the screen
{
xPosition=480;//move it to the right of the screen
}
}
}
class Townhouse
{
var xPosition;
var yPosition;
var speedX;
var r;
var g;
var b;
Townhouse(xPos, yPos, xSpeed,color)
{
xPosition = xPos;
yPosition = yPos;
speedX = xSpeed;
r= color[0];
g= color[1];
b= color[2];
}
void drawTownhouse()
{
//line(-20, 376, 418, 376);
noStroke();
fill (r, g, b);
triangle(xPosition+26, yPosition+161, xPosition+147, yPosition+161, xPosition+87, yPosition+137); //triangle
fill (r, g, b);
rect(xPosition+26, yPosition+173, 121, 201); //red building
fill(145, 181, 181);
rect(xPosition+28, yPosition+163, 116, 7); //top
fill(145, 181, 181);
rect(xPosition+36, yPosition+181, 24, 40); //top left window
fill(145, 181, 181);
rect(xPosition+73, yPosition+181, 24, 40); //top middle window
fill(145, 181, 181);
rect(xPosition+110, yPosition+181, 24, 40); //top right window
fill(145, 181, 181);
rect(xPosition+36, yPosition+228, 24, 40); //middle left building
fill(145, 181, 181);
rect(xPosition+73, yPosition+228, 24, 40); //middle middle window
fill(145, 181, 181);
rect(xPosition+110, yPosition+228, 24, 40); // middle right window
fill(145, 181, 181);
rect(xPosition+36, yPosition+275, 24, 40); //bottom left window
fill(145, 181, 181);
rect(xPosition+73, yPosition+275, 24, 40); //bottom middle window
fill(145, 181, 181);
rect(xPosition+110, yPosition+275, 24, 40); //bottom right window
fill(145, 181, 181);
rect(xPosition+36, yPosition+323, 24, 40); //ground left window
fill(145, 181, 181);
rect(xPosition+73, yPosition+323, 24, 40); //ground middle window
fill(44, 136, 138);
rect(xPosition+108, yPosition+322, 29, 52); //door
fill(0, 0, 0);
ellipse(xPosition+113, yPosition+352, 2, 2); //door knob
}
void moveTownhouse()
{
xPosition = xPosition + speedX;
if(xPosition < -130)//when the house is off the screen
{
xPosition=480;//move it to the right of the screen
}
}
}
class Car
{
var r;
var g;
var b;
var Xpos;
var Ypos;
var speedX;
Car(color,xp,yp,sp)
{
r= color[0];
g= color[1];
b= color[2];
Xpos= xp;
Ypos= yp;
speedX= sp;
}
void drawCar()
{
noStroke();
fill(r,g,b);
rect(Xpos,Ypos,100,30);
arc(Xpos+50,Ypos-7,75,70,180,360);
fill(0,0,0);
ellipse(Xpos+20,Ypos+30,25,25);
ellipse(Xpos+80,Ypos+30,25,25);
}
void moveCar()
{
Xpos = Xpos+ speedX;
if(Xpos < -130)
{
Xpos = 480;
}
}
}
class Coin
{
var xPosition;
var yPosition;
var speedX;
var r;
var g;
var b;
Coin(xPos, yPos, xSpeed,color)
{
xPosition = xPos;
yPosition = yPos;
speedX = xSpeed;
r= color[0];
g= color[1];
b= color[2];
}
void drawCoin()
{
//coins
stroke(222, 192, 40); //orange border
strokeWeight(2); //size of the orange border
fill(225, 255, 0);
ellipse(xPosition+200,yPosition+200,20,20); //yellow circle
}
void moveCoin()
{
xPosition = xPosition + speedX;
if(xPosition < 2)//when the house is off the screen
{
xPosition=480;//move it to the right of the screen
}
}
}
class Condo{
var xPos;
var yPpos;
var speedX;
Condo(xp,yp,sp)
{
xPos= xp;
yPos= yp;
speedX= sp;
}
void drawCondo()
{
noStroke();
fill(204, 194, 194);
rect(xPos,yPos,175,300);//building
//fill(141, 138, 150);
//quad(xPos,yPos,xPos-10,yPos-20,xPos+185,yPos-20,xPos+175,yPos);//roof
//stroke(56, 64, 94);
//strokeWeight(2);
fill(119, 137, 156);
rect(xPos+20,yPos+20,50,40);//windows
rect(xPos+100,yPos+20,50,40);//windows
rect(xPos+20,yPos+80,50,40);//windows
rect(xPos+100,yPos+80,50,40);//windows
rect(xPos+20,yPos+140,50,40);//windows
rect(xPos+100,yPos+140,50,40);//windows
//stroke(91, 99, 117);
//strokeWeight(2);
rect(xPos+57.5,yPos+227,30,70);//doors
rect(xPos+90.5,yPos+227,30,70);//doors
//stroke(92, 173, 94);
//strokeWeight(1.75);
fill(32, 153, 36);
ellipse(xPos+30,yPos+285,45,45);//bush
}
void moveCondo()
{
xPos = xPos+ speedX;
if(xPos < -160)
{
xPos = 650;
}
}
}
class Cone
{
var xPosition;
var yPosition;
var speedX;
var r;
var g;
var b;
Cone(xPos, yPos, xSpeed,color)
{
xPosition = xPos;
yPosition = yPos;
speedX = xSpeed;
r= color[0];
g= color[1];
b= color[2];
}
void drawCone()
{
fill(255, 102, 0);
triangle(xPosition+17,yPosition+380,xPosition+58,yPosition+380,xPosition+36,yPosition+335); //cone's triangle
stroke(232, 202, 111);//
strokeWeight(1.6); //yellow line's width
fill(196, 94, 4);
ellipse(xPosition+37,yPosition+384,50,13);//bottom of the cone
noStroke();
}
void moveCone()
{
xPosition = xPosition + speedX;
if(xPosition < 2)//when the house is off the screen
{
xPosition=480;//move it to the right of the screen
}
}
}