package com.osnova;
import android.view.*;
import android.graphics.*;






public class DrawThread extends Thread {

	private boolean running = false;
	private SurfaceHolder surfaceHolder;
    DD dd;

	
	
	
	public DrawThread(SurfaceHolder surfaceHolder,DD dd) {
       
		      this.surfaceHolder = surfaceHolder;
	       this.dd=dd;
		
		
		
		
		}

	public void setRunning(boolean running) {
        this.running = running;
	}

	@Override
	public void run() {
        Canvas c;
		
	   
		////Fps.start_2();
		 
	   
	   while (running) {
			c = null;
			 
			
			Fps.start_1(); 
			try {
				c = surfaceHolder.lockCanvas();
				if (c == null)
				continue;
				
			///Fps.fps_2();
				
			/* if(Fps.delta>1) {
					Fps.delta-=Fps.delta;}*/
				 dd.draw(c);
			//	}
			
			
				Fps.fps_1();
				
				
				try{
					this.sleep(Fps.wTime); 
				}catch(Exception e){}
			
				
				
			 
			  
				
					
			} finally {
				if (c != null) {
					surfaceHolder.unlockCanvasAndPost(c);}}
        }
	}
    //////////end
	

	
	

	
	
}
