I'm trying to make a code that has several orbiting images, a moon orbiting the earth, and then a smaller moon orbiting the moon. Getting the main moon orbiting the earth wasn't too difficult, it just requires rotating the moon image around the center of the earth. However, I can't figure out how to get the smaller moon rotating around the big one. Any ideas on how to do this? The images I'm using are attached.
Moon.jpgoie_transparent.jpgRocket.jpgGalaxy2.jpgimport java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JPanel; public class GUIs extends JFrame { private Image earth = Toolkit.getDefaultToolkit().getImage("picFolder/Earth.gif"); private Image back = Toolkit.getDefaultToolkit().getImage("picFolder/galaxy2.png"); private Image rocket = Toolkit.getDefaultToolkit().getImage("picFolder/Rocket.gif"); private Image moon = Toolkit.getDefaultToolkit().getImage("picFolder/Moon.png"); public void makeEnvironment() { setTitle("This is the title"); setBounds(0, 0, 800, 800); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MyPanel panel = new MyPanel(); panel.setBackground(Color.white); getContentPane().add(panel); setResizable(true); setVisible(true); } private class MyPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(back,0,0,1280,1024,this); Graphics2D g2d = (Graphics2D)g; drawStuff(g, g2d); } } public static void main(String[] args) { GUIs gui = new GUIs(); gui.makeEnvironment(); } public int rCurrent = 0; public int rIncrement = 1; public void drawStuff(Graphics g, Graphics2D g2d) { Thread thread = new Thread(); try{Thread.sleep(1);} catch(InterruptedException e){e.printStackTrace();} g.drawImage(earth, 200, 200, 100, 100, this); g2d.rotate(Math.PI*(rCurrent)/360, 250, 250); g.drawImage(moon, 400, 210, 60, 60, this); g2d.rotate(Math.PI*(rCurrent*3)/360, 250, 250); g.drawImage(rocket, 150, 240, 20, 20, this); rCurrent+=rIncrement; repaint(); } }