2013-01-20 1 views
-1
// The "Animation" class. 
import java.awt.*; 
import hsa.Console; 

public class Animation 
{ 
    static Console c;   // The output console 


    public static void main (String[] args) throws InterruptedException 
    { 
     c = new Console(); 


     for (int index = 0 ; index < 300 ; index += 10) 
     { 



      // This is the night sky  
      c.setColor (Color.black); 
      c.fillRect (0, 0, 1500, 700); 
      c.drawRect (0, 0, 1500, 700); 

      // This is the moon 
      c.setColor (Color.white); 
      c.fillOval (550, 10, 80, 90); 

      // These are the stars in the background 
      c.setColor (Color.yellow); 
      c.fillStar (50, 70, 20, 20); 
      c.fillStar (90, 100, 20, 20); 
      c.fillStar (130, 70, 20, 20); 
      c.fillStar (210, 70, 20, 20); 
      c.fillStar (290, 70, 20, 20); 
      c.fillStar (370, 70, 20, 20); 
      c.fillStar (450, 70, 20, 20); 
      c.fillStar (170, 100, 20, 20); 
      c.fillStar (250, 100, 20, 20); 
      c.fillStar (330, 100, 20, 20); 
      c.fillStar (410, 100, 20, 20); 

      // This is the shooting star 
      c.fillStar (index, index, index + 20, index + 10); 

      Thread.sleep (1400); 




     } 

     // Place your program here. 'c' is the output console 
    } // main method 
} // Animation class 

우리는 컴퓨터 과학 분야에서 우리의 작업을 수행하고 있으며, 우리의 지식을 Java로 사용하여 간단한 애니메이션을 실행할 수있는 프로그램을 구성합니다. 이것은 내가 지금까지 가지고있는 코드이다. 슈팅 스타가 점점 더 커지면서 문제는 계속되고 있지만, 나는 그것을 1 크기로 유지하고 싶다. 어떤 제안이 있나?간단한 움직이는 애니메이션을하는 좋은 방법?

답변

0

widthheight 매개 변수에 index을 사용하고 있기 때문입니다. 또한이 API에 대한 Javadoc은 here이라고 가정합니다.

c.fillStar(index, index, 20, 10); 
+0

이 감사에 의해

 c.fillStar (index, index, index + 20, index + 10); 

교체 : 그렇다면, 내가 좋아하는 뭔가를 건의 할 것입니다! –

0

작동

 c.fillStar (index, index, 20, 10); 
관련 문제