summaryrefslogtreecommitdiff
path: root/Year_2/IandM/02232021_1/Auto.pde
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-02-23 19:07:56 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-02-24 19:07:56 +0100
commit49805bf316bd9ed1a8dcbd829a0c28b9399d1ff3 (patch)
tree34fa1afdb30b44bccc9803d0f241c9d97e3862a8 /Year_2/IandM/02232021_1/Auto.pde
parentcf228fd6b77a0efbdd4846d41a436663f2ae7eb1 (diff)
i&m: exercises of 23rd feb
Diffstat (limited to 'Year_2/IandM/02232021_1/Auto.pde')
-rwxr-xr-xYear_2/IandM/02232021_1/Auto.pde29
1 files changed, 29 insertions, 0 deletions
diff --git a/Year_2/IandM/02232021_1/Auto.pde b/Year_2/IandM/02232021_1/Auto.pde
new file mode 100755
index 0000000..62c3181
--- /dev/null
+++ b/Year_2/IandM/02232021_1/Auto.pde
@@ -0,0 +1,29 @@
+class Auto {
+ private int posx;
+ private int posy;
+
+ private float velx = random(2, 10); // [2, 10);
+
+ private int MYCOLOR = #007CA0; // this is blue
+
+ public Auto() {
+ this.posx = -60;
+ this.posy = 512/3;
+ }
+
+ public float velx() {
+ return this.velx;
+ }
+
+ void draw() {
+ rectMode(CORNER);
+ noStroke();
+ fill(this.MYCOLOR);
+ rect(posx, posy, 60, 30);
+ posx += velx;
+
+ if(posx >= 512) {
+ posx = -60;
+ }
+ }
+}