I am trying to create an interactive photo where, when you click and hold the mouse, the planets begin to rotate around the sun... I just can't get it where I want it. I'm not sure how. Can someone please help?
var x = 35
var y = 120
var d = 80
var cols, rows;
var w = 50;
var grid = [];
function setup(){
// this function will run once
createCanvas(320, 240); // create a 320x240 pixel drawing canvas
}
function draw(){
background(255); //light gray background
if (mouseIsPressed == true) {
background(0); //black background
fill(255,153,51);//orange
ellipse(x-62,y,d,d);// sun
rotate(radians(frameCount));
}
fill(163,210,6);//green
ellipse((x+52),y,d-7,d-7);//jupiter
fill(239,233,49);//yellow
ellipse((x+95),y,d-14,d-14);//saturn
fill(49,239,239);//neon blue
ellipse((x+192),y,d-21,d-21)//uranus
fill(201,49,239);//purple
ellipse((x+301),y,d-28,d-28);//neptune
fill(0,85,255);//blue
ellipse((x+10),y,d-35,d-35);//earth
fill(255, 51, 153);//pink
ellipse((x+7.2),y,d-42,d-42);//venus
fill(210,95,6);//red
ellipse((x+15),y,d-49,d-49);//mars
fill(64,64,64);//gray
ellipse((x+3.8),y,(d-56),(d-56));//mercury
}
<script src="https://cdn.jsdelivr.net/npm/p5@1.0.0/lib/p5.min.js"></script>
