public void run()
	{
		init();
		
		//For keeping track of nanoTime
		long start;
		long elapsed;
		long wait;
		
		while(running)
		{
			//The start time of the function call
			start = System.nanoTime();
			
			//update variables, create and draw images
			update(); 
			draw();   
			drawToScreen();  
			
			//set the amount of time the function took
			elapsed = System.nanoTime()-start;

			//pauses the thread to maintain 60 fps
			wait = targetTime-elapsed/1000000;
			if (wait < 0) wait = 5;
			try
			{
				Thread.sleep(wait);	
			}
			catch(Exception e)
			{
				System.out.println(e.getMessage());
				e.printStackTrace();
			}
		}
	}