Created
August 10, 2018 21:59
-
-
Save patricoferris/ea0d9b9c6f09613cecfee9593658ad35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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