15
Nov
The init() Method The first line of code
The init() Method The first line of code constructs a bouncing boxes world. After that, a magic camera is constructed, through which we will view the world. The run() Method In the run() method we keep track of how long a frame takes to render. If a frame takes more than 0.2 seconds to render, then the hardware is too slow or the OS is too busy, so we set the update time to 0.2 seconds. The world and the camera are updated. The next thing we would like to do is paint the world as seen through the camera. To accelerate the rendering, we will ignore the repaint() request and simply tell Java s AWT to paint. This method will drastically increase the rendering speed but can also cause problems due to the inner workings of Java. To insure that no major malfunction occurs, a couple of checks are done: Is there an actual window to paint on? If so, is the window real or a bogus window with no dimension? The paint() Method In the paint() method we ensure that the camera has the right screen dimensions and then tell it to paint. As you can see in Listing 12-4, the HTML file contains quite a few parameters that can be changed to customize the applet. You can experiment by changing the ourDefaultPolyhedron parameter, telling the bouncing box to use some other 3D model, or you can change the gravity of the world if you like. Listing 12-4 The HTML file
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services
