Check if character sees other character

how to check if enimy sees midas? if i3 is 1, enimy looks to the left and if its 2 he looks to the right.


//characters

int midashp= 30;

int enimyhp= 30;

PImage[] midas= new PImage[8];
PImage[] reversemidas= new PImage[8];
PImage[] daughter= new PImage[3];
PImage[] enemy= new PImage[3];
PImage[] reverseenemy= new PImage[8];
PImage battlescreen;

boolean showMidas1= true;

//coordinates
float midasx= 1;
float midasy= 1;

float daughterx= width;
float daughtery= height;

float enemyprevx;
float enemyx= width-(width/4);

//i's
int i=1;
int i2= 1;
int i3= 1;

//hpwidth
int hpwidth1= midashp*5.66666666667 ;
int hpwidth2= enimyhp*5.66666666667;


void setup() {
  size(600, 600);

  //load characters in
  midas[1] = loadImage("1.png");
  midas[2] = loadImage("2.png");
  midas[3] = loadImage("3.png");
  midas[4] = loadImage("4.png");
  midas[5] = loadImage("5.png");
  midas[6] = loadImage("6.png");
  midas[7] = loadImage("7.png");

  reversemidas[1] = loadImage("rev1.png");
  reversemidas[2] = loadImage("rev2.png");
  reversemidas[3] = loadImage("rev3.png");
  reversemidas[4] = loadImage("rev4.png");
  reversemidas[5] = loadImage("rev5.png");
  reversemidas[6] = loadImage("rev6.png");
  reversemidas[7] = loadImage("rev7.png");

  daughter[1] = loadImage("daughter.png");
  daughter[2] = loadImage("daughter gold.png");

  enemy[1]= loadImage("enemy1.png");
  enemy[2]= loadImage("revenimy.png");
	
	battlescreen=("battlescreen.png")
}
void draw() {
  background(0, 0, 0);
  tint(255, 255);
  //show and move the characters

  if (frameCount%120 == 0) {
    i3 = 1;
  }
  if (frameCount%120 == 60) {
    i3 = 2;
  }

  image(enemy[i3], enemyx, height-(height/4), 50, 80);


  if (dist(midasx, midasy, daughterx, daughtery) < 45) {
    i2=2;
  }

  image(daughter[i2], daughterx, daughtery, 40, 70);

  if (showMidas1==true&& ! keyPressed) {
    image(midas[1], midasx, midasy, 50, 80);
  } 
  if (keyPressed) {
    if (key == 'w') {
      midasy=midasy-10;
      image(midas[i], midasx, midasy, 50, 80);
      showMidas1= false;
    }
  }
  if (keyPressed) {
    if (key == 's') {
      midasy=midasy+10;
      image(midas[i], midasx, midasy, 50, 80);
      showMidas1= false;
    }
  }
  if (keyPressed) {
    if (key == 'a') {
      midasx=midasx-10;
      image(reversemidas[i], midasx, midasy, 50, 80);
      showMidas1= false;
    }
  }
  if (keyPressed) {
    if (key == 'd') {
      midasx=midasx + 10;
      image(midas[i], midasx, midasy, 50, 80);
      showMidas1= false;
    }
  }

  if (i==7) {
    i=1;
  }


  i++;
}

void keyReleased() {
  showMidas1 = true;
}

Hey take a look at that:
Time: 2:39 explanation