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

191
Vistas
Khan Academy: Spaceship Ride

For Challenge: Spaceship Ride in Khan Academy's Advanced JS: Natural Simulations in the computer programming category in the computing course, I need to speed the ships up, turn them upside down, and spin those ships around. this is the default code: angleMode = "radians";

var Spaceship = function() {
this.angle = new PVector();
this.velocity = new PVector(random(-0.01, 0.01), random(-0.01, 0.01));
this.amplitude = new PVector(random(20, width/2), random(20, width/2));
this.position = new PVector(0, 0);
};

Spaceship.prototype.oscillate = function() {
this.angle.add(this.velocity);
this.position.set(
sin(this.angle.x) * this.amplitude.x,
sin(this.angle.y) * this.amplitude.y);
};

Spaceship.prototype.display = function() {
pushMatrix();
translate(width/2, height/2);
stroke(181, 63, 0);
strokeWeight(9);
line(0, 0, this.position.x, this.position.y);
imageMode(CENTER);
image(getImage("space/octopus"),
this.position.x, this.position.y,
80, 100);
popMatrix();
};

var ships = [];
for (var i = 0; i < 10; i++) {
ships.push(new Spaceship());
}

draw = function() {
background(174, 218, 232);
for (var i = 0; i < ships.length; i++) {
    ships[i].oscillate();
    ships[i].display();
}
};

Can you please tell me what I need to change or add?

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