Skip to content

Instantly share code, notes, and snippets.

@wonderburg7
Created December 12, 2018 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wonderburg7/d038188ea28bdd547aeceb87946d5bd5 to your computer and use it in GitHub Desktop.
Save wonderburg7/d038188ea28bdd547aeceb87946d5bd5 to your computer and use it in GitHub Desktop.
PImage img1, img2, img3, img4, img5, img6;
float orbitDuration;
float orbitRad = 100;
float ang, x, y;
float rotationCounter = 0;
void setup()
{
size(900,900);
fill(255);
stroke(255);
img1 = loadImage("https://i.ibb.co/jHzy1FQ/Star-white-small.png");
img2 = loadImage("https://i.ibb.co/HqmVKhj/Rocky-Planet-white-small.png");
img3 = loadImage("https://i.ibb.co/xqyV2pC/Gas-Giant-white-small.png");
img4 = loadImage("https://i.ibb.co/WgCtb98/Gas-Giant-with-ring-white-small.png");
img5 = loadImage("https://i.ibb.co/ckMnzWQ/Planet-without-space-station-white-small.png");
img6 = loadImage("https://i.ibb.co/HrLTPDb/Space-station-white-small.png");
/* img1 = loadImage("Star-white.png");
img2 = loadImage("Rocky Planet-white.png");
img3 = loadImage("Gas Giant-white.png");
img4 = loadImage("Gas Giant with ring-white.png");
img5 = loadImage("Planet without space station-white.png");
img6 = loadImage("Space station-white.png"); */
imageMode(CENTER);
int picheight = 100, picwidth = 100;
img1.resize(picheight, picwidth);
img2.resize(picheight, picwidth);
img3.resize(picheight, picwidth);
img4.resize(picheight, picwidth);
img5.resize(picheight, picwidth);
img6.resize(picheight, picwidth);
}
void draw()
{
background(0,0);
translate(width/2,height/2);
// ellipse(0,0,50,50);
image(img1, 0, 0);
orbitRad = 80;
orbitDuration = 5*1000; // 5 second orbit
ang = TWO_PI * millis()/orbitDuration;
x = cos(ang)*orbitRad;
y = sin(ang)*orbitRad;
image(img2, x, y);
orbitRad = 120;
orbitDuration = 10*1000; //
ang = TWO_PI * millis()/orbitDuration;
x = cos(ang)*orbitRad;
y = sin(ang)*orbitRad;
image(img2, x, y);
ellipse(x, y, 10, 10);
pushMatrix();
translate(x, y);
orbitDuration = 1*1000; //
ang = TWO_PI * millis()/orbitDuration;
noFill();
x = cos(ang)*25;
y = sin(ang)*25;
ellipse(x, y, 10, 10);
fill(255);
popMatrix();
orbitRad = 180;
orbitDuration = 15*1000; //
ang = TWO_PI * millis()/orbitDuration;
x = cos(ang)*orbitRad;
y = sin(ang)*orbitRad;
image(img5, x, y);
pushMatrix();
translate(x, y);
// rotate(radians(rotationCounter));
orbitDuration = 1*1000; //
ang = TWO_PI * millis()/orbitDuration;
noFill();
x = cos(ang)*30;
y = sin(ang)*30;
image(img6, x, y);
fill(255);
popMatrix();
orbitRad = 250;
orbitDuration = 12*1000; // 5 second orbit
ang = TWO_PI * millis()/orbitDuration;
x = cos(ang)*orbitRad;
y = sin(ang)*orbitRad;
image(img4, x, y);
pushMatrix();
translate(x, y);
orbitDuration = 1.5*1000; //
ang = TWO_PI * millis()/orbitDuration;
x = cos(ang-1)*35;
y = sin(ang-1)*35;
ellipse(x, y, 10, 10);
x = cos(ang-.5)*35;
y = sin(ang-.5)*35;
ellipse(x, y, 10, 10);
popMatrix();
orbitRad = 320;
orbitDuration = 13*1000; // 14 second orbit
ang = TWO_PI * millis()/orbitDuration;
x = cos(ang)*orbitRad;
y = sin(ang)*orbitRad;
image(img3, x, y);
pushMatrix();
translate(x, y);
orbitDuration = 2*1000; //
ang = TWO_PI * millis()/orbitDuration;
noFill();
x = cos(ang)*43;
y = sin(ang)*43;
ellipse(x, y, 10, 10);
fill(255);
x = cos(ang-1)*43;
y = sin(ang-1)*43;
ellipse(x, y, 10, 10);
x = cos(ang-.5)*43;
y = sin(ang-.5)*43;
ellipse(x, y, 10, 10);
popMatrix();
orbitRad = 360;
orbitDuration = 16*1000; // 16 second orbit
ang = TWO_PI * millis()/orbitDuration;
x = cos(ang)*orbitRad;
y = sin(ang)*orbitRad;
image(img2, x, y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment