public void run(){
		gameStart=0;
		new Tile();
		windowrunning = true;
		running = true;
		level = new Level();

		image = createVolatileImage(width,height);

		//Run the application until the user tells it to close
		while(windowrunning){
			if(gameStart==1){
				startTime = System.currentTimeMillis();
				gameStart++;
			}

			if(running)
				currentTime = System.currentTimeMillis();

			update();//go to update()
			render();//renders the grid after checking conditions and changing tile images

			//If you hit a bomb, end the game
			if(hitBomb){
				Level.revealBombs(Level.grid);
				update();
				render();
				Level.endGame(false);
				hitBomb=false;
			}

			//If you win, end the game
			if(gamewon){
				update();
				render();
				stopTime = System.currentTimeMillis();
				Level.endGame(true);
				gamewon=false;
			}

			//Close the window
			if(gtfo){
				windowrunning=false;
				j.setVisible(false);
				j.dispose();
			}

			//Wait a bit so as not to render more than necessary
			try{
				Thread.sleep(15);
			} catch(Exception e){
				e.printStackTrace();
			}
		}

		//Close the window when the application has been told to stop running
		if(gtfo){
			windowrunning=false;
			j.setVisible(false);
			j.dispose();
		}
	}