Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!