public void checkTrainerEncounter()
	{
		if(cartographer)
			return;

		for(int i=0; i<numTrainers; i++)
		{
			if(trainer[i] != null && trainer[i].hostile)
				switch(trainer[i].direction)
				{
					case 0:
						if(location.x<=trainer[i].location.x+trainer[i].viewRange&&location.x>trainer[i].location.x&&location.y==trainer[i].location.y)
						{
							bgm.stop();
							surfSong.stop();
							bikeSong.stop();

							if(trainer[i].type==Trainer.TrainerType.RIVAL)
								rivalEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.GYM_LEADER||trainer[i].type==Trainer.TrainerType.ELITE
								||trainer[i].type==Trainer.TrainerType.BABB)
								leaderEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.PROFESSOR||trainer[i].type==Trainer.TrainerType.JAVA)
								evilEncounter.loop();
							else if(trainer[i].gender==1)
								femaleEncounter.loop();
							else
								maleEncounter.loop();

							trainerToFight=i;
							trainerEnc=true;

							try
							{
								repaint();
								Thread.sleep(2500);
							}
							catch(Exception ignored){}
						}
						break;
					case 90:
						if(location.y>=trainer[i].location.y-trainer[i].viewRange&&location.y<trainer[i].location.y&&location.x==trainer[i].location.x)
						{
							bgm.stop();
							surfSong.stop();
							bikeSong.stop();

							if(trainer[i].type==Trainer.TrainerType.RIVAL)
								rivalEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.GYM_LEADER||trainer[i].type==Trainer.TrainerType.ELITE
								||trainer[i].type==Trainer.TrainerType.BABB)
								leaderEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.PROFESSOR||trainer[i].type==Trainer.TrainerType.JAVA)
								evilEncounter.loop();
							else if(trainer[i].gender==1)
								femaleEncounter.loop();
							else
								maleEncounter.loop();

							trainerToFight=i;
							trainerEnc=true;

							try
							{
								repaint();
								Thread.sleep(2500);
							}
							catch(Exception ignored){}
						}
						break;
					case 180:
						if(location.x>=trainer[i].location.x-trainer[i].viewRange&&location.x<trainer[i].location.x&&location.y==trainer[i].location.y)
						{
							bgm.stop();
							surfSong.stop();
							bikeSong.stop();

							if(trainer[i].type==Trainer.TrainerType.RIVAL)
								rivalEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.GYM_LEADER||trainer[i].type==Trainer.TrainerType.ELITE
								||trainer[i].type==Trainer.TrainerType.BABB)
								leaderEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.PROFESSOR||trainer[i].type==Trainer.TrainerType.JAVA)
								evilEncounter.loop();
							else if(trainer[i].gender==1)
								femaleEncounter.loop();
							else
								maleEncounter.loop();

							trainerToFight=i;
							trainerEnc=true;

							try
							{
								repaint();
								Thread.sleep(2500);
							}
							catch(Exception ignored){}
						}
						break;
					case 270:
						if(location.y<=trainer[i].location.y+trainer[i].viewRange&&location.y>trainer[i].location.y&&location.x==trainer[i].location.x)
						{
							bgm.stop();
							surfSong.stop();
							bikeSong.stop();

							if(trainer[i].type==Trainer.TrainerType.RIVAL)
								rivalEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.GYM_LEADER||trainer[i].type==Trainer.TrainerType.ELITE
								||trainer[i].type==Trainer.TrainerType.BABB)
								leaderEncounter.loop();
							else if(trainer[i].type==Trainer.TrainerType.PROFESSOR||trainer[i].type==Trainer.TrainerType.JAVA)
								evilEncounter.loop();
							else if(trainer[i].gender==1)
								femaleEncounter.loop();
							else
								maleEncounter.loop();

							trainerToFight=i;
							trainerEnc=true;

							try
							{
								repaint();
								Thread.sleep(2500);
							}
							catch(Exception ignored){}
						}
						break;
				}
		}
	}