Skip to content

Instantly share code, notes, and snippets.

@patricoferris
Created August 10, 2018 21:59
Show Gist options
  • Save patricoferris/ea0d9b9c6f09613cecfee9593658ad35 to your computer and use it in GitHub Desktop.
Save patricoferris/ea0d9b9c6f09613cecfee9593658ad35 to your computer and use it in GitHub Desktop.
class Planet {
//The 'build' method
constructor(position, mass, radius, color) {
this.position = position;
//A p5 Vector
this.velocity = createVector(0, 0);
this.mass = mass;
this.radius = radius;
this.color = color;
}
show() {
//pushing and popping is like save and restore
push();
//that way we can translate over to here
translate(this.position.x, this.position.y);
fill(this.color);
//draw our planet
ellipse(0, 0, this.radius, this.radius);
//and pop back to wherever we were before
pop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment