14
Nov
The parameter name starts with the class name,
lastUpdate=System.currentTimeMillis(); while(alive){ long currentTime=System.currentTimeMillis(); long dtmillis=currentTime-lastUpdate; double dt=(double)dtmillis/1000; lastUpdate=currentTime; //– make sure the update doesn’t take to large “steps” if(dt>0.2) dt=0.2; world.update(dt); camera.update(dt); //– to speed up the repaint we tell the Applet to update //– directly instead of calling repaint if(getPeer()==null) return; Graphics g=getGraphics(); if(g==null) return; Dimension dim=size(); if(dim.width==0 || dim.height==0) return; update(g); } } public void start () { if(myThread==null){ myThread=new Thread(this); myThread.start(); alive=true; } } public void paint(Graphics g){ //– update the screen size for the camera camera.setScreenSize(size().width,size().height); //– erase the screen g.clearRect(0,0,size().width,size().height); //– paint the world camera.paint(g); } public void stop () { if(myThread!=null){ myThread.stop(); myThread=null; alive=false; } } }
Note: If you are looking for cheap and reliable provider to host and run your servlet application check Vision servlet hosting services
