var planets = []; var planet = function(color, size, position, speed, name) { this.color = color; this.size = size; this.x = 0; this.y = position; this.rotation = 0; this.speed = speed; this.name = name; }; var createPlanets = function() { planets.push(new planet(color(112, 16, 16), 15, 60, 2, "Mars")); planets.push(new planet(color(188, 66, 66), 10, 80, 1.75, "Jupiter")); planets.push(new planet(color(88, 117, 188), 20, 100, 1.5, "Venus")); planets.push(new planet(color(255, 0, 0), 15, 120, 1.25, "Uranus")); planets.push(new planet(color(224, 187, 132), 35, 150, 1, "Neptune")); planets.push(new planet(color(255, 240, 219), 20, 200, 0.75, "Saturn")); planets.push(new planet(color(66, 140, 214), 20, 200, 0.5, "Earth")); planets.push(new planet(color(67, 125, 135), 20, 220, 0.25, "Mercury")); planets.push(new planet(color(136, 146, 147), 5, 230, 0.10, "Pluto")); }; createPlanets(); var drawPlanets = function() { for(var i = 0; i < planets.length; i++) { translate(200, 200); rotate(planets[i].rotation); planets[i].rotation += planets[i].speed; fill(planets[i].color); ellipse(0, planets[i].y, planets[i].size, planets[i].size); fill(); text(planets[i].name, planets[i].x, planets[i].y); resetMatrix(); } }; var draw = function() { background(0); fill(255, 255, 0); ellipse(200, 200, 100, 100); drawPlanets(); };