summaryrefslogtreecommitdiff
path: root/Year_2/IandM/02232021_1/Auto.pde
blob: 62c31815886f56077f002e6361049ec1962a053b (plain)
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
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;
    }
  }
}