9. สร้างใหม่จากเก่า

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 9-22  ตัวอย่างโปรแกรมใช้งาน Ball3D, Ball3DColor, และ Ball3DImage
import jlab.graphics.*;

public class TestBall3D {
  public static void main(String[] args) {
    int h = 200, h2 = h/2;
    DWindow3D w = new DWindow3D(h, h, h);
    Ball3D[] balls = new Ball3D[] {
           new Ball3DColor(DWindow.BLACK, 10, h2, h2, h2),
           new Ball3DColor(DWindow.BLUE, 15, h2, h2, h2),
           new Ball3DImage("c:/java101/fball.gif", h2, h2, h2) };
    w.setRepaintDuringSleep(true);
    while (true) {
      w.clearBackground();
      w.drawFrame(50);
      for (int i = 0; i < balls.length; i++) {
        balls[i].move(w);
        balls[i].draw(w);
      }
      w.sleep(50);
    }
  }
}
©2009 S.Prasitjutrakul