Planet = {
function Planet(center, radius, orbitRadius, velocity, color) {
this.center = center;
this.x = center.x + orbitRadius;
this.y = center.y;
this.lastX = this.x;
this.lastY = this.y;
this.radius = radius;
this.orbitRadius = orbitRadius || 0;
this.velocity = velocity || 0;
this.theta = 0;
this.color = color || "black";
}
Planet.prototype.update = function (delta) {
this.lastX = this.x;
this.lastY = this.y;
this.theta += this.velocity * delta;
this.x = this.center.x + Math.cos(this.theta) * this.orbitRadius;
this.y = this.center.y + Math.sin(this.theta) * this.orbitRadius;
};
Planet.prototype.draw = function (interpolationPercentage) {
var x = this.lastX + (this.x - this.lastX) * interpolationPercentage,
y = this.lastY + (this.y - this.lastY) * interpolationPercentage;
context.circle(x, y, this.radius, this.color);
};
return Planet;
}