Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
Image is misaligned when speed is accelerating p5.js

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda