From 49805bf316bd9ed1a8dcbd829a0c28b9399d1ff3 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 23 Feb 2021 19:07:56 +0100 Subject: i&m: exercises of 23rd feb --- Year_2/IandM/02232021_1/Auto.pde | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 Year_2/IandM/02232021_1/Auto.pde (limited to 'Year_2/IandM/02232021_1/Auto.pde') 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; + } + } +} -- cgit v1.2.3-18-g5258