我正在制作一个太阳系模拟器,但在移动行星时遇到麻烦,蓝色圆圈应该绕太阳旋转,但是当我运行程序时,除了不断闪烁之外,没有任何其他动作。

我的代码:

public class solar
{
  public static void main(String args[])
  {
    while (true) {


    SolarSystem x = new SolarSystem(500,500);
    x.drawSolarObject(0,0,50,"YELLOW");
    x.drawSolarObject(90,45,20,"BLUE");

    x.finishedDrawing();

    }
  }
}


我从正在使用的类中调用了方法,例如drawSolarObject包含距离,角度,直径,颜色。

任何帮助将不胜感激谢谢。

最佳答案

尝试这个...

public class solar
{
  public static void main(String args[])
    int i = 0;
    {
       while (true) {

          SolarSystem x = new SolarSystem(500,500);
          x.drawSolarObject(0,0,50,"YELLOW");
          x.drawSolarObject(90,i,20,"BLUE");

          i++;

          x.finishedDrawing();

    }
  }
}


角度在每次迭代中改变一个。

10-06 04:51