summaryrefslogtreecommitdiffstats
path: root/Year_2/IandM/02232021_1/AutoElettrica.pde
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-02-23 18:07:56 +0000
committerSanto Cariotti <santo@dcariotti.me>2021-02-24 18:07:56 +0000
commit49805bf316bd9ed1a8dcbd829a0c28b9399d1ff3 (patch)
tree34fa1afdb30b44bccc9803d0f241c9d97e3862a8 /Year_2/IandM/02232021_1/AutoElettrica.pde
parentcf228fd6b77a0efbdd4846d41a436663f2ae7eb1 (diff)
i&m: exercises of 23rd feb
Diffstat (limited to 'Year_2/IandM/02232021_1/AutoElettrica.pde')
-rwxr-xr-xYear_2/IandM/02232021_1/AutoElettrica.pde29
1 files changed, 29 insertions, 0 deletions
diff --git a/Year_2/IandM/02232021_1/AutoElettrica.pde b/Year_2/IandM/02232021_1/AutoElettrica.pde
new file mode 100755
index 0000000..f952b29
--- /dev/null
+++ b/Year_2/IandM/02232021_1/AutoElettrica.pde
@@ -0,0 +1,29 @@
+class AutoElettrica extends Auto {
+ private int MYCOLOR = (int)random(0, 255);
+ private boolean triangle_turn = true;
+
+ AutoElettrica(float velx) {
+ super.velx = velx/2;
+ super.posx = -60;
+ super.posy = 512*2/3;
+ }
+
+ void draw() {
+ rectMode(CORNER);
+ noStroke();
+ fill(this.MYCOLOR);
+ rect(super.posx, super.posy, 60, 30);
+ super.posx += super.velx;
+
+ fill(#EFFC38); // triangle color, this is yellow
+
+ if (this.triangle_turn) {
+ triangle(super.posx+30, super.posy, super.posx+60, super.posy+30, super.posx, super.posy+30);
+ }
+
+ if (super.posx >= 512) {
+ super.posx = -60;
+ this.triangle_turn = !this.triangle_turn;
+ }
+ }
+}