12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- int x;
- int y;
- int r = 200;
- void setup()
- {
- size(640, 480);
- background(0,0,0);
- x = 0;
- y = 0;
- }
- void draw()
- {
- float t = millis() / 1000.0f;
- x = (int) (350 + (r * cos(t) * 1.3));
- y = (int) (240 + r * sin(t));
-
- background(0,0,0);
-
- //orbit
- stroke(0, 0, 255, 128);
- fill(0,0,0,0);
- ellipse(240, 1240, 2000, 2000);
-
- //planet
- stroke(0,255,0, 255);
- fill(0,255,0, 0);
- ellipse(250, 240, 150, 150);
- stroke(255,0,0, 255);
- fill(255,0,0,255);
- rect(250 - 5, 240 - 4, 10, 8);
-
- //orbit
- stroke(0, 0, 255, 128);
- fill(0,0,0,0);
- ellipse(350, 240, 520, 400);
-
- //moon
- stroke(128,128,128,255);
- fill(128,128,128,0);
- ellipse(x, y, 48, 48);
- stroke(255,255,0,255);
- fill(255,255,0,255);
- rect(x - 5, y - 4, 10, 8);
-
- }
|