summaryrefslogtreecommitdiff
path: root/Year_2/IandM/02232021_1/Auto.pde
diff options
context:
space:
mode:
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;
+ }
+ }
+}