0

when these are ran the images slowly become misaligned with a gap between the two images.

class Road{
  constructor(image ,x, y, rWidth, rHeight, calcSpeed){
    this.image = image;
    this.x = x;
    this.y = y;
    this.width = rWidth;
    this.height = rHeight;
    this.speed = calcSpeed;
  }
  
  static setupRoad() {
    let tempRoad1 = new Road(roadBack, 0, 0, sW, sH, mainSpeed);
    let tempRoad2 = new Road(roadBack, 0, 0 - sH, sW, sH, mainSpeed);
  
    roadImages.push(tempRoad1, tempRoad2);
  }

  display (){
    image(this.image,this.x,this.y,this.width,this.height);
  }
  
  update (){
    

    this.y += this.speed;
    this.speed = mainSpeed;
  
  
  if(this.y >= sH){
    this.y = -this.height;
   }
  }
}
class Car {
  constructor(speed){
this.speed = speed //speed would be zero 0
}
movement (){
    if(keyIsDown(87)) {
      mainSpeed = this.speed;
      if(this.speed < goSpeed){
        this.speed += .25;
      }
   
    }
    else {
      mainSpeed = stopSpeed;
      this.speed = 0;
  }

}

Just a point in the right direction would be legendary.

Paul Wheeler
  • 18,988
  • 3
  • 28
  • 41
Kgduder
  • 21
  • 3
  • You need to provide enough code to reproduce your issue: https://stackoverflow.com/help/minimal-reproducible-example preferably as a [runnable snippet](https://stackoverflow.com/a/67410652/229247). – Paul Wheeler Nov 28 '21 at 23:59
  • Also, it would be more clear if you described what you want to achieve with this code more precisely. As-is, this question looks like "I wrote this, doesn't work like I wanted, plz fix". – Maciej B. Nowak Dec 03 '21 at 08:40

0 Answers0